:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #68747d;
  --line: #dfe5e8;
  --brand: #116466;
  --brand-2: #c94c32;
  --ok: #247a3d;
  --warn: #a66a00;
  --bad: #b3261e;
  --shadow: 0 10px 30px rgba(18, 38, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: 252px 1fr;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.login-screen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #edf3f2;
}

.login-screen.hidden {
  display: none;
}

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

.login-card h1 {
  font-size: 24px;
}

.login-card p,
.login-error {
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 6px;
}

.login-card input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login-error {
  min-height: 20px;
  color: var(--bad);
}

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

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

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

button.ghost {
  background: #eef3f3;
  color: var(--brand);
}

button.icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #eef1f2;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.sidebar {
  min-height: 100vh;
  padding: 22px 16px;
  background: #15262b;
  color: #fff;
}

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

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.brand-mark img {
  display: block;
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #b9c7cb;
  font-size: 12px;
}

.user-box {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #dce5e8;
  font-size: 13px;
}

.user-box button {
  width: 100%;
  padding: 7px 10px;
}

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

.nav-btn {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  background: transparent;
  color: #dce5e8;
  text-align: left;
}

.nav-btn.active {
  background: #243a41;
  color: #fff;
}

.nav-count {
  color: #9fb0b5;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

.topbar p,
.muted {
  margin-top: 6px;
  color: var(--muted);
}

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

.inventory-toolbar-actions {
  flex-wrap: nowrap;
  align-items: center;
}

.inventory-toolbar-actions button,
.inventory-toolbar-actions select {
  flex: 0 0 auto;
}

.inventory-toolbar-actions select {
  max-width: 190px;
}

.toolbar-select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi,
.panel,
dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi {
  padding: 16px;
}

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

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  overflow: hidden;
}

.panel header,
dialog header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel h3 {
  font-size: 16px;
}

.panel-body {
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 760px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
  overflow-x: auto;
}

.summary-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

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

.summary-chip b {
  font-size: 13px;
  font-weight: 800;
}

.summary-chip.strong {
  border-color: #b9d4cf;
  background: #eef7f5;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f9fbfb;
}

tr:last-child td {
  border-bottom: 0;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions button {
  padding: 6px 10px;
}

.table-actions .icon-action {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.table-actions .icon-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-actions .text-action {
  min-width: 58px;
  padding: 6px 8px;
  font-size: 12px;
}

.table-actions .danger-action {
  color: var(--bad);
  background: #fde7e4;
}

.table-actions .save-action {
  color: #fff;
  background: var(--ok);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 99px;
  color: #17434b;
  background: #e6f2f0;
  font-size: 12px;
}

.status.warn {
  color: var(--warn);
  background: #fff4df;
}

.status.bad {
  color: var(--bad);
  background: #fde7e4;
}

.status.ok {
  color: var(--ok);
  background: #e8f5eb;
}

.dashboard-alert-row td {
  color: var(--bad);
  font-weight: 700;
}

.dashboard-alert-row .status {
  color: var(--bad);
  background: #fde7e4;
}

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

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

.subtabs button {
  min-width: 92px;
}

.group-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: -4px 0 14px;
}

.group-tabs[hidden] {
  display: none;
}

.module-switcher-card {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  box-shadow: 0 4px 14px rgba(18, 38, 44, 0.04);
  white-space: normal;
}

.module-switcher-card:hover {
  filter: none;
  border-color: rgba(17, 100, 102, 0.35);
}

.module-switcher-card.active {
  border-color: var(--brand);
  background: #edf6f5;
  box-shadow: inset 0 0 0 1px rgba(17, 100, 102, 0.18), 0 5px 16px rgba(18, 38, 44, 0.06);
}

.module-switcher-card strong {
  font-size: 15px;
  line-height: 1.25;
}

.module-switcher-card span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.module-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #d7251d;
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 5px 12px rgba(120, 22, 18, 0.25);
}

.toolbar input {
  width: min(420px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.search-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto;
  gap: 8px;
  width: min(560px, 100%);
}

.search-wrap input {
  width: 100%;
}

.search-suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  width: min(420px, 100%);
  max-height: 260px;
  overflow-y: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-suggestions:empty {
  display: none;
}

.search-suggestions button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.search-suggestions button:hover {
  background: #eef3f3;
}

dialog {
  width: min(840px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: hidden;
}

dialog form {
  display: flex;
  max-height: calc(100vh - 28px);
  flex-direction: column;
}

dialog::backdrop {
  background: rgba(15, 25, 28, 0.42);
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.form-error {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid #f1b8b4;
  border-radius: 6px;
  background: #fff0ee;
  color: var(--bad);
  font-size: 13px;
  font-weight: 800;
}

.page-editor .form-error {
  margin: 12px 16px 0;
}

.form-error[hidden] {
  display: none;
}

.inbound-fields {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

.inbound-fields > :not(.inbound-metric) {
  grid-column: span 6;
}

.inbound-fields .inbound-top {
  grid-column: span 4;
}

.inbound-fields .inbound-status {
  grid-column: 1 / -1;
}

.inbound-fields .inbound-metric {
  grid-column: span 3;
}

.inbound-fields .inbound-metric input {
  min-height: 44px;
  font-size: 18px;
  font-weight: 800;
  text-align: right;
}

.inbound-fields .inbound-estimate input {
  border-color: #cbd5d1;
  background: #f6f8f7;
  color: var(--accent);
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.family-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf9;
}

.family-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.family-editor-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.family-editor-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.family-editor-rows {
  display: grid;
  gap: 10px;
}

.family-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

.pdf-upload-field {
  display: grid;
  gap: 8px;
}

.pdf-upload-box {
  display: grid;
  grid-template-columns: minmax(190px, 0.55fr) 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf9;
}

.pdf-upload-box input[type="file"] {
  width: 100%;
  min-height: 38px;
  padding: 7px;
  background: #fff;
}

.pdf-upload-box span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf9;
}

.document-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.document-editor-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.document-editor-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.document-current-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.document-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.document-card-title {
  color: var(--text);
  font-weight: 800;
}

.document-preview {
  display: grid;
  height: 118px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #cbd5d1;
  border-radius: 6px;
  background: #f3f6f5;
  color: var(--muted);
  font-weight: 800;
}

.document-preview-button {
  width: 100%;
  padding: 0;
  cursor: zoom-in;
}

.document-preview-button:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 126, 96, 0.12);
}

.document-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdf-preview {
  color: var(--brand);
  font-size: 22px;
}

.document-card-meta {
  min-height: 34px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.document-upload-panel {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(150px, 0.8fr) minmax(190px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.document-history {
  display: grid;
  gap: 8px;
}

.document-history > strong {
  color: var(--text);
}

.document-history-row {
  display: grid;
  grid-template-columns: 0.8fr 1fr auto;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.document-history-row b {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-viewer {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 15, 17, 0.72);
}

.document-viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(980px, 100%);
  height: min(92vh, 760px);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.document-viewer-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.document-viewer-panel header strong,
.document-viewer-panel header span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-viewer-panel header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.document-viewer-body {
  min-height: 0;
  overflow: auto;
  background: #eef2f1;
}

.document-viewer-body img {
  display: block;
  max-width: 100%;
  min-height: 100%;
  margin: 0 auto;
  object-fit: contain;
}

.document-viewer-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.permission-grid legend {
  padding: 0 6px;
  color: var(--muted);
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-editor {
  min-height: calc(100vh - 132px);
  overflow: hidden;
  background: #fff;
}

.page-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.page-editor-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.page-editor-head p {
  margin: 0;
  color: var(--muted);
}

.page-fields {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  align-items: start;
}

.page-fields .full {
  grid-column: 1 / -1;
}

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding-top: 20px;
  color: var(--text);
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

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

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

.full {
  grid-column: 1 / -1;
}

dialog footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.notice-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfb;
  color: var(--muted);
  font-size: 13px;
}

.notice-box strong {
  grid-column: 1 / -1;
  color: var(--text);
}

.lot-picker {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.lot-picker-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
}

.lot-picker table {
  min-width: 1180px;
}

.lot-picker th,
.lot-picker td {
  padding: 9px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.lot-picker tbody tr {
  cursor: pointer;
}

.lot-picker tbody tr:hover {
  background: #f4f8f8;
}

.lot-picker tbody tr.selected {
  background: #e6f2f0;
}

.lot-picker button:disabled {
  cursor: not-allowed;
  background: #e2e7e8;
  color: #8a969c;
  filter: none;
}

.sale-lines input {
  min-width: 92px;
  padding: 7px 8px;
}

.trace-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

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

.compact-panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.alias-manager-panel .panel-body {
  padding: 0;
}

.alias-manager-table {
  min-width: 700px;
}

.alias-manager-table th:nth-child(1),
.alias-manager-table td:nth-child(1) {
  width: 190px;
}

.alias-manager-table td:first-child {
  display: grid;
  gap: 2px;
}

.alias-manager-table th,
.alias-manager-table td {
  padding: 7px 9px;
  font-size: 13px;
}

.alias-manager-table td:first-child strong {
  line-height: 1.25;
}

.alias-manager-table td:first-child span {
  overflow: hidden;
  max-width: 180px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-input-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr)) auto;
  gap: 6px;
  align-items: center;
}

.alias-input-grid input {
  min-width: 0;
  padding: 6px 7px;
  font-size: 13px;
}

.icon-mini-button {
  width: 32px;
  min-width: 32px;
  padding: 5px 0;
  font-size: 17px;
  font-weight: 800;
}

.inventory-group {
  margin-bottom: 16px;
}

.inventory-group-head h3 {
  font-size: 18px;
}

.inventory-total-panel {
  margin-bottom: 16px;
}

.inventory-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-left: 5px solid var(--accent);
  background: #fff7ed;
}

.inventory-total span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.inventory-total strong {
  padding: 4px 10px;
  border-radius: 6px;
  background: #f97316;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
}

.inventory-amount-highlight {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffedd5;
  color: #c2410c;
  font-weight: 900;
}

.inventory-ownership-panel {
  margin-bottom: 12px;
}

.inventory-ownership-panel .compact-panel-head {
  align-items: center;
  padding: 10px 12px;
}

.inventory-ownership-panel .compact-panel-head h3 {
  font-size: 14px;
}

.ownership-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  padding: 8px 10px 10px;
}

.ownership-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  align-items: baseline;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: #fbfcfc;
  text-align: left;
}

.ownership-card.active {
  border-color: var(--accent);
  background: #e9f2f1;
  color: var(--accent);
}

.ownership-card span {
  font-size: 13px;
  font-weight: 800;
}

.ownership-card strong {
  color: var(--text);
  font-size: 13px;
  text-align: right;
}

.ownership-card em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.dispatch-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 8px 0;
  background: var(--bg);
}

.dispatch-date-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.dispatch-planner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  align-items: start;
}

.dispatch-date-box,
.dispatch-driver-box,
.dispatch-stat-box {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

.dispatch-date-box {
  display: grid;
  gap: 8px;
}

.dispatch-date-box h4,
.dispatch-driver-box h4,
.dispatch-stat-box h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.dispatch-date-box > strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.dispatch-calendar {
  display: grid;
  gap: 5px;
}

.dispatch-calendar-head {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 5px;
}

.dispatch-calendar-head span {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.dispatch-calendar-head button {
  min-width: 30px;
  padding: 4px 0;
}

.dispatch-calendar-weekdays,
.dispatch-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.dispatch-calendar-weekdays span {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.dispatch-calendar-day {
  display: grid;
  place-items: center;
  min-height: 31px;
  padding: 3px 1px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.dispatch-calendar-day span {
  line-height: 1;
}

.dispatch-calendar-day em {
  overflow: hidden;
  max-width: 100%;
  color: var(--accent);
  font-size: 9px;
  font-style: normal;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-calendar-day.other-month {
  opacity: 0.42;
}

.dispatch-calendar-day.today {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px #dc2626;
}

.dispatch-calendar-day.today em {
  color: #b91c1c;
}

.dispatch-calendar-day.selected {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
  box-shadow: none;
}

.dispatch-calendar-day.today.selected {
  border-color: #dc2626;
  background: linear-gradient(135deg, #dc2626 0 48%, #2563eb 52% 100%);
  color: #fff;
  box-shadow: none;
}

.dispatch-calendar-day.selected em {
  color: #eff6ff;
}

.dispatch-date-buttons,
.dispatch-box-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.dispatch-box-footer {
  justify-content: space-between;
  font-size: 13px;
}

.dispatch-date-controls,
.dispatch-date-chips,
.dispatch-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.dispatch-top-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.dispatch-date-box input {
  flex: 0 0 150px;
  min-width: 100%;
  width: 100%;
  padding: 7px 8px;
}

.dispatch-date-box button,
.dispatch-top-actions button {
  padding: 7px 9px;
}

.dispatch-top-actions select {
  min-width: 140px;
  width: 140px;
}

.dispatch-date-chips button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.dispatch-date-chips span {
  color: var(--muted);
  font-size: 12px;
}

.dispatch-stat-box {
  overflow-x: auto;
}

.compact-stats-table th,
.compact-stats-table td {
  padding: 8px 10px;
  font-size: 13px;
}

.vehicle-stats-table {
  min-width: 260px;
}

.vehicle-stats-table td:nth-child(1) {
  min-width: 110px;
}

.vehicle-stat-cell {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.vehicle-stat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mini-button {
  padding: 5px 7px;
  font-size: 12px;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.dispatch-customer-preview.inline {
  min-height: auto;
}

.compact-empty {
  padding: 12px;
}

.daily-driver-compact {
  display: grid;
  gap: 8px;
  align-items: stretch;
  padding: 0;
  border: 0;
  background: transparent;
}

.daily-driver-compact > strong {
  white-space: nowrap;
  font-size: 14px;
}

.daily-driver-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.daily-driver-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.daily-driver-card span {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-driver-card select {
  padding: 5px 7px;
  font-size: 13px;
}

.daily-driver-compact > button {
  justify-self: end;
  padding: 7px 12px;
}

.dispatch-driver-select {
  width: 100%;
}

@media (max-width: 920px) {
  .dispatch-planner-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .dispatch-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .dispatch-planner-grid {
    grid-template-columns: 1fr;
  }
}

.dispatch-summary-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.dispatch-summary-card strong {
  color: var(--text);
  font-size: 14px;
}

.dispatch-summary-title {
  cursor: pointer;
}

.dispatch-summary-card.waiting {
  border-color: #f0b7a8;
  background: #fff7f4;
}

.dispatch-order-count {
  color: var(--bad);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.dispatch-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dispatch-summary-actions button {
  padding: 6px 8px;
  font-size: 12px;
}

.dispatch-customer-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 25px;
}

.dispatch-customer-preview span,
.dispatch-customer-preview em {
  padding: 3px 6px;
  border-radius: 999px;
  background: #eef5f5;
  color: var(--text);
  font-size: 12px;
  font-style: normal;
}

.dispatch-message-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.dispatch-message-grid label {
  min-width: 0;
}

.dispatch-message-grid textarea {
  min-height: 360px;
  resize: vertical;
}

@media (max-width: 1280px) {
  .dispatch-message-grid {
    grid-auto-columns: minmax(160px, 1fr);
  }
}

.dispatch-vehicle-select {
  min-width: 150px;
}

.dispatch-pick-sheet {
  break-inside: avoid;
  scroll-margin-top: 128px;
}

.print-only {
  display: none;
}

.dispatch-pick-head {
  align-items: stretch;
  background: #fbfcfc;
}

.dispatch-pick-head h3 {
  font-size: 20px;
}

.dispatch-detail-panel {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fffdf7;
}

.dispatch-detail-list {
  display: grid;
  gap: 8px;
}

.dispatch-customer-list {
  display: grid;
  gap: 8px;
}

.dispatch-customer-item {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.dispatch-customer-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.dispatch-customer-overview {
  margin-bottom: 14px;
  border-color: #b9d8d4;
}

.dispatch-customer-table {
  min-width: 1080px;
}

.dispatch-customer-table th,
.dispatch-customer-table td {
  border: 1px solid var(--line);
}

.dispatch-customer-table tfoot td {
  background: #f7fbfa;
  font-weight: 800;
}

.dispatch-detail-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.dispatch-detail-item strong {
  white-space: pre-line;
}

.dispatch-pick-footer span {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.dispatch-pick-table {
  min-width: 980px;
}

.dispatch-pick-table th,
.dispatch-pick-table td {
  border: 1px solid var(--line);
}

.dispatch-pick-table tr.dispatch-unarranged-row td {
  background: #fff6e5;
}

.dispatch-pick-table tr.dispatch-unarranged-row td:first-child {
  border-left: 4px solid var(--warn);
}

.dispatch-pick-table th:nth-child(1),
.dispatch-pick-table td:nth-child(1) {
  width: 52px;
  text-align: center;
}

.dispatch-pick-table th:nth-child(3),
.dispatch-pick-table td:nth-child(3) {
  min-width: 150px;
}

.dispatch-pick-table th:nth-child(4),
.dispatch-pick-table td:nth-child(4) {
  min-width: 420px;
  white-space: pre-line;
}

.dispatch-pick-table th:nth-child(5),
.dispatch-pick-table td:nth-child(5) {
  width: 96px;
}

.dispatch-inline-input {
  min-width: 90px;
  padding: 7px 8px;
}

.dispatch-inline-textarea {
  width: 100%;
  min-height: 54px;
  resize: vertical;
}

.dispatch-line-items {
  display: grid;
  gap: 4px;
  min-width: 420px;
}

.dispatch-line-items-head,
.dispatch-line-item-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 100px;
  gap: 6px;
  align-items: stretch;
}

.dispatch-line-items-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dispatch-line-detail {
  min-height: 34px;
  resize: vertical;
}

.dispatch-line-quantity {
  min-width: 86px;
}

.dispatch-customer-table td:nth-child(2) .dispatch-inline-input,
.dispatch-customer-table td:nth-child(6) .dispatch-inline-input {
  min-width: 140px;
}

.dispatch-no {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.dispatch-pick-footer {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfc;
}

.compact-select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

  .sidebar {
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 12px;
  }

  nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpis,
  .grid,
  .fields,
  .notice-box,
  .trace-summary {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    justify-content: flex-start;
  }

  .page-editor-head {
    flex-direction: column;
  }

  .page-fields {
    grid-template-columns: 1fr;
  }

  .inbound-fields > *,
  .inbound-fields .inbound-metric {
    grid-column: 1 / -1;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;

    @bottom-right {
      content: "";
      font-size: 9pt;
    }
  }

  body {
    display: block;
    background: #fff;
  }

  .sidebar,
  .topbar,
  .toolbar,
  .subtabs,
  .dispatch-date-panel,
  .dispatch-import,
  .daily-driver-compact,
  .dispatch-overview,
  .dispatch-detail-panel,
  .dispatch-pick-head,
  .dispatch-pick-table,
  .dispatch-vehicle-select,
  .table-actions,
  .dispatch-pick-table th:nth-child(6),
  .dispatch-pick-table td:nth-child(6),
  .dispatch-pick-table th:nth-child(7),
  .dispatch-pick-table td:nth-child(7) {
    display: none !important;
  }

  .main {
    padding: 0;
  }

  .panel,
  .dispatch-pick-sheet {
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    page-break-inside: auto;
    break-inside: auto;
  }

  .dispatch-pick-sheet {
    page-break-after: always;
  }

  .dispatch-pick-sheet:last-child {
    page-break-after: auto;
  }

  body.print-dispatch-single .dispatch-pick-sheet {
    display: none !important;
  }

  body.print-dispatch-single .dispatch-pick-sheet.print-target {
    display: block !important;
    page-break-after: auto;
  }

  .dispatch-pick-head,
  .dispatch-pick-footer {
    background: #fff;
  }

  .print-only {
    display: block;
  }

  .dispatch-pick-footer span {
    border-color: #222;
    border-radius: 0;
    background: #fff;
  }

  .panel-body {
    overflow: visible;
  }

  .dispatch-print-head {
    padding: 10mm 8mm 7mm;
    border-bottom: 2px solid #111;
  }

  .dispatch-print-system {
    display: block;
    text-align: center;
  }

  .dispatch-print-system strong {
    font-size: 20px;
    letter-spacing: 0;
  }

  .dispatch-print-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 8px;
  }

  .dispatch-print-title h2 {
    margin: 0;
    font-size: 24px;
  }

  .dispatch-print-title span {
    min-width: 160px;
    text-align: right;
    font-size: 16px;
    font-weight: 800;
    transform: translateX(-15ch);
  }

  .dispatch-print-orders {
    display: block;
    padding: 7mm 14mm 18mm 8mm;
  }

  .dispatch-print-column {
    display: grid;
    align-content: start;
    gap: 8px;
  }

  .dispatch-print-note-space {
    display: none;
  }

  .dispatch-print-note-space::before {
    content: "备注";
    position: absolute;
    top: 8px;
    left: 10px;
    color: #555;
    font-size: 12pt;
    font-weight: 800;
  }

  .dispatch-print-order {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 6px;
    min-height: 52px;
    padding: 7px;
    border: 0;
    box-sizing: border-box;
    break-inside: avoid;
  }

  .dispatch-print-order span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid #222;
    font-size: 13px;
    font-weight: 800;
  }

  .dispatch-print-order p {
    margin: 0;
    color: #000;
    font-size: 12pt;
    line-height: 1.35;
    white-space: pre-line;
  }

  .dispatch-print-order strong {
    display: block;
    margin-bottom: 5px;
    color: #000;
    font-size: 12pt;
  }

  .dispatch-print-line-table {
    width: calc(100% - 1mm);
    border-collapse: collapse;
    border: 0;
    color: #000;
    font-size: 12pt;
    table-layout: fixed;
    box-sizing: border-box;
  }

  .dispatch-print-line-table th,
  .dispatch-print-line-table td {
    padding: 5px 6px;
    border: 0;
    text-align: left;
    vertical-align: top;
    box-sizing: border-box;
  }

  .dispatch-print-line-table th:first-child,
  .dispatch-print-line-table td:first-child {
    width: 50%;
  }

  .dispatch-print-line-table th:last-child,
  .dispatch-print-line-table td:last-child {
    width: 50%;
    padding-left: 6px;
  }

  .dispatch-print-line-table th {
    border-bottom: 0;
  }

  .dispatch-print-line-table tbody tr + tr td {
    border-top: 1px dashed #c9c9c9;
  }

  .dispatch-print-line-table td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .dispatch-print-order.dispatch-unarranged-row {
    background: #fff2cc !important;
  }

  .dispatch-print-footer {
    position: fixed;
    right: 8mm;
    bottom: 5mm;
    left: 8mm;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    align-items: center;
    border-top: 1px solid #222;
    padding-top: 3mm;
    color: #000;
    font-size: 10pt;
  }

  .dispatch-print-footer span:last-child {
    justify-self: end;
  }

  .dispatch-print-page-count::after {
    content: "";
  }

  .dispatch-driver-list-print {
    display: none;
  }

  body.print-driver-list .dispatch-date-panel,
  body.print-driver-list .dispatch-print-head,
  body.print-driver-list .dispatch-print-orders,
  body.print-driver-list .dispatch-print-footer {
    display: none !important;
  }

  body.print-driver-list .dispatch-driver-list-print {
    display: block !important;
    padding: 10mm 8mm;
  }

  .dispatch-driver-list-page {
    page-break-after: always;
  }

  .dispatch-driver-list-page:last-child {
    page-break-after: auto;
  }

  .dispatch-driver-list-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 16px;
    align-items: start;
    margin-bottom: 14px;
    color: #000;
  }

  .dispatch-driver-list-head h2 {
    grid-column: 1 / -1;
    margin: 0;
    text-align: center;
    font-size: 20pt;
  }

  .dispatch-driver-list-head span {
    font-size: 12pt;
  }

  .dispatch-driver-list-head strong {
    justify-self: end;
    font-size: 13pt;
  }

  .dispatch-driver-print-table {
    width: 100%;
    box-sizing: border-box;
    border-collapse: collapse;
    border-right: 3px solid #222;
    border-bottom: 2px solid #222;
    font-size: 12pt;
    table-layout: fixed;
  }

  .dispatch-driver-print-table th,
  .dispatch-driver-print-table td {
    box-sizing: border-box;
    padding: 5px 5px;
    border: 1px solid #222;
    color: #000;
    text-align: left;
    vertical-align: top;
  }

  .dispatch-driver-print-table th:nth-child(1),
  .dispatch-driver-print-table td:nth-child(1) {
    width: 8mm;
    text-align: center;
  }

  .dispatch-driver-print-table th:nth-child(2),
  .dispatch-driver-print-table td:nth-child(2) {
    width: 32mm;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .dispatch-driver-print-table th:nth-child(3),
  .dispatch-driver-print-table td:nth-child(3) {
    width: 17mm;
  }

  .dispatch-driver-print-table th:nth-child(4),
  .dispatch-driver-print-table td:nth-child(4),
  .dispatch-driver-print-table th:nth-child(7),
  .dispatch-driver-print-table td:nth-child(7) {
    width: 21mm;
  }

  .dispatch-driver-print-table th:nth-child(5),
  .dispatch-driver-print-table td:nth-child(5),
  .dispatch-driver-print-table th:nth-child(6),
  .dispatch-driver-print-table td:nth-child(6) {
    width: 15mm;
  }

  .dispatch-driver-print-table th:nth-child(8),
  .dispatch-driver-print-table td:nth-child(8) {
    width: 30mm;
    white-space: normal;
    overflow-wrap: anywhere;
    border-right: 3px solid #222;
  }

  .dispatch-driver-print-table tfoot td {
    font-weight: 800;
  }

  .dispatch-empty-customer-row td {
    height: 8mm;
  }
}


@media (max-width: 640px) {
  body {
    display: block;
    font-size: 14px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 8px 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  }

  .brand {
    gap: 9px;
    margin-bottom: 8px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 7px;
  }

  .brand-mark img {
    width: 39px;
    height: 39px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand span {
    font-size: 11px;
  }

  .user-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    padding: 7px 8px;
  }

  .user-box button {
    width: auto;
    min-height: 32px;
    padding: 5px 10px;
  }

  nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 1px 0 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .nav-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 96px;
    justify-content: center;
    gap: 6px;
    padding: 9px 10px;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
  }

  .nav-count {
    display: inline-flex;
    min-width: 18px;
    justify-content: center;
  }

  .main {
    padding: 12px 10px 18px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .group-tabs {
    display: flex;
    gap: 8px;
    margin: -2px -2px 12px;
    padding: 2px 2px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .module-switcher-card {
    flex: 0 0 auto;
    width: min(76vw, 260px);
    min-height: 82px;
    padding: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .topbar p,
  .muted {
    font-size: 13px;
  }

  .actions,
  .toolbar .actions {
    width: 100%;
    gap: 8px;
  }

  .actions button,
  .toolbar .actions button,
  .toolbar .actions select {
    flex: 1 1 auto;
    min-width: 0;
  }

  button {
    min-height: 40px;
    padding: 9px 11px;
  }

  input,
  select,
  textarea {
    min-height: 40px;
    font-size: 16px;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi {
    padding: 12px;
  }

  .kpi strong {
    font-size: 20px;
  }

  .panel,
  dialog {
    border-radius: 7px;
  }

  .panel header,
  dialog header {
    padding: 12px;
  }

  .panel-body {
    overflow-x: auto;
  }

  .table-summary {
    min-width: 620px;
    padding: 8px 10px;
  }

  .summary-chip {
    padding: 6px 8px;
  }

  table {
    min-width: 680px;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  td {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .table-actions {
    flex-wrap: nowrap;
  }

  .table-actions .text-action {
    min-width: 52px;
  }

  .toolbar {
    gap: 8px;
  }

  .inventory-toolbar-actions {
    flex-wrap: wrap;
  }

  .inventory-toolbar-actions select {
    max-width: none;
    width: 100%;
  }

  .search-wrap {
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .search-wrap input {
    min-width: 0;
  }

  .search-suggestions {
    width: 100%;
  }

  dialog {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
  }

  dialog form {
    max-height: calc(100vh - 12px);
  }

  .fields {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    max-height: none;
  }

  .family-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .pdf-upload-box {
    grid-template-columns: 1fr;
  }

  .document-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .document-upload-panel,
  .document-history-row {
    grid-template-columns: 1fr;
  }

  dialog footer {
    padding: 12px;
  }

  dialog footer button {
    flex: 1 1 0;
  }

  .page-editor {
    min-height: auto;
    border-radius: 7px;
  }

  .page-editor-head {
    padding: 12px;
  }

  .page-editor-head h2 {
    font-size: 20px;
  }

  .page-fields {
    grid-template-columns: 1fr;
    padding: 12px;
    max-height: none;
  }

  .notice-box,
  .trace-summary {
    grid-template-columns: 1fr;
  }

  .lot-picker table {
    min-width: 980px;
  }

  .sale-lines input {
    min-width: 76px;
  }

  .dispatch-batch-grid,
  .dispatch-overview-grid,
  .dispatch-summary-grid,
  .dispatch-vehicle-grid,
  .dispatch-customer-grid {
    grid-template-columns: 1fr;
  }

  .dispatch-pick-footer {
    grid-template-columns: 1fr;
  }

  .dispatch-line-items,
  .dispatch-line-items-head,
  .dispatch-line-item-row {
    min-width: 320px;
  }

  .dispatch-line-items-head,
  .dispatch-line-item-row {
    grid-template-columns: minmax(190px, 1fr) 88px;
  }
}

@media (max-width: 420px) {
  .kpis {
    grid-template-columns: 1fr;
  }

  .search-wrap {
    grid-template-columns: 1fr;
  }

  .search-wrap button {
    width: 100%;
  }

  table {
    min-width: 620px;
  }

  .table-summary {
    min-width: 560px;
  }

  .nav-btn {
    min-width: 86px;
    padding-inline: 8px;
  }

  .brand strong {
    font-size: 13px;
  }
}
