:root {
  --ink: #1f2937;
  --muted: #64748b;
  --paper: #f5f7fa;
  --surface: #ffffff;
  --line: #dce3ea;
  --brand: #0f766e;
  --brand-soft: #e6f4f1;
  --action: #2563eb;
  --action-hover: #1d4ed8;
  --sidebar: #182733;
  --danger: #a1372d;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15.5px;
  line-height: 1.5;
}

a { color: var(--brand); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 220px;
  flex-direction: column;
  padding: 24px 16px 18px;
  background: var(--sidebar);
  color: #fff;
}

.brand {
  display: block;
  margin: 0 6px 28px;
  color: #fff;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: .01em;
  line-height: 1.35;
  text-decoration: none;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-nav a {
  border-radius: 8px;
  color: #dbe5eb;
  padding: 10px 12px;
  font-weight: 650;
  text-decoration: none;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  background: #ffffff12;
  color: #fff;
}

.side-nav a.active {
  background: var(--brand-soft);
  color: #115e59;
}

.side-nav-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
}

.side-nav-item .nav-main { min-width: 0; }
.side-nav .task-badge {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #8f1d2c;
  color: #fff;
  font-size: .78rem;
  line-height: 1.35;
  text-align: center;
}
.side-nav .pending-task-link {
  min-width: max-content;
  padding-inline: 9px;
}

.menu-pending {
  border-radius: 999px;
  background: #8f1d2c;
  color: #fff;
  padding: 2px 7px;
  font-size: .74rem;
  font-weight: 800;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.account-panel {
  display: grid;
  gap: 3px;
  margin-top: auto;
  border-top: 1px solid #ffffff24;
  padding: 16px 6px 0;
}

.account-name {
  overflow-wrap: anywhere;
  font-weight: 750;
}

.account-role {
  color: #aebdc7;
  font-size: .86rem;
}

.menu-toggle { display: none; }

.app-main.with-sidebar { margin-left: 220px; }

.page-toolbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
  background: #f5f7faf2;
  padding: 8px max(24px, calc((100% - 1180px) / 2));
  backdrop-filter: blur(8px);
}

.top-logout { margin: 0; }

.container {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .14em;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 32px);
  line-height: 1.15;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.25rem;
}

h3,
h4,
h5 { margin: 0; }

.panel,
.card,
.login-card,
.allocation-row,
.line-form {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 18px #1827330a;
}

.panel {
  margin: 14px 0;
  padding: 20px;
}

.allocation-row,
.line-form {
  margin: 12px 0;
  padding: 16px;
}

.narrow { max-width: 860px; }

.stack { max-width: 1040px; }

.login-card {
  max-width: 480px;
  margin: 10vh auto;
  padding: 32px;
}

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

.shipment-cards,
.shipment-list,
.order-groups {
  display: grid;
  gap: 14px;
}

.shipment-cards { grid-template-columns: 1fr; }

.card { padding: 18px; }

.card-top,
.actions,
.checklist,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.status,
.tag {
  display: inline-block;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #115e59;
  padding: 3px 9px;
  font-size: .82rem;
}

.line {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.product-status-block,
.inventory-factory,
.shipment-history-factory {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.product-status-block:first-of-type,
.inventory-factory:first-child,
.shipment-history-factory:first-child { border-top: 0; padding-top: 0; }

.status-counts {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.status-counts div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 9px 10px;
}

.status-counts dt { color: var(--muted); font-size: .82rem; }
.status-counts dd { margin: 2px 0 0; font-size: 1.12rem; font-weight: 800; }
.device-status-group { margin-top: 10px; }
.device-status-group h3 { margin-bottom: 6px; color: var(--muted); font-size: .9rem; }

.inventory-factories,
.shipment-history-groups { display: grid; gap: 16px; }
.inventory-order { margin-top: 12px; border-left: 3px solid var(--brand-soft); padding-left: 14px; }
.inventory-order h4 { margin: 0 0 8px; }
.inventory-line { border-top: 1px solid var(--line); padding: 10px 0; }
.scope-feedback:empty { display: none; }

.shipment-create-disclosure > summary {
  cursor: pointer;
  list-style-position: outside;
  font-size: 1.08rem;
}
.shipment-create-disclosure > summary span { display: inline-grid; gap: 3px; }
.shipment-create-disclosure > summary small {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 400;
}
.shipment-create-disclosure[open] > summary { margin-bottom: 16px; }
.shipment-create-content { min-width: 0; }

.customer-overview-panel { display: grid; gap: 16px; }
.overview-search {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
}
.overview-search label { grid-column: 1 / -1; font-weight: 700; }
.overview-totals,
.customer-overview-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin: 0;
}
.overview-totals div,
.customer-overview-card dl div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 10px;
}
.overview-totals dt,
.customer-overview-card dt { color: var(--muted); font-size: .82rem; }
.overview-totals dd,
.customer-overview-card dd { margin: 2px 0 0; font-size: 1.12rem; font-weight: 800; }
.customer-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.customer-overview-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  overflow-wrap: anywhere;
}
.customer-overview-card h3 { margin-bottom: 12px; }
.customer-overview-card dl { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; }
.customer-overview-card .customer-delivery-products,
.customer-overview-card .customer-order-previews { flex: 1 0 auto; }
.customer-overview-card > .actions,
.customer-overview-card > .button { margin-top: auto; }
.logistics-editor { margin-top: 14px; }
.logistics-editor > summary.button { display: inline-flex; width: auto; }
.logistics-editor[open] > summary { margin-bottom: 12px; }
.shipment-cancel-form {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.shipment-scope-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.shipment-scope-summary div { border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0; }
.shipment-scope-summary dt { color: var(--muted); font-size: .84rem; }
.shipment-scope-summary dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.customer-orders-table { table-layout: fixed; }
.customer-orders-table th:nth-child(1) { width: 20%; }
.customer-orders-table th:nth-child(2) { width: 20%; }
.customer-orders-table th:nth-child(3) { width: 14%; }
.customer-orders-table th:nth-child(4) { width: 34%; }
.customer-orders-table th:nth-child(5) { width: 12%; }
.customer-orders-table td { min-width: 0; overflow-wrap: anywhere; }
.customer-order-customer strong,
.customer-order-number strong { display: block; }
.customer-order-products { display: grid; gap: 4px; }
.order-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.task-action {
  border-color: #9f1239;
  background: #9f1239;
  color: #fff;
}
.task-action:hover,
.task-action:focus-visible { background: #881337; color: #fff; }
.pending-shipment-guidance {
  margin: 12px 0;
  border-left: 4px solid #9f1239;
  border-radius: 8px;
  background: #fff1f2;
  padding: 11px 12px;
}
.pending-shipment-guidance ul { margin: 8px 0 0; padding-left: 20px; }

.shipment-device-groups { display: grid; gap: 12px; }
.shipment-device-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.shipment-device-group legend { padding: 0 5px; }
.device-choice-list { display: grid; gap: 7px; margin-top: 10px; }

.status-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 14px;
  overflow-x: auto;
}

.status-tabs a,
.pagination a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 12px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.status-tabs a.active,
.pagination a.active {
  border-color: #a5d6ce;
  background: var(--brand-soft);
  color: #115e59;
}

.filter-panel { padding-top: 14px; padding-bottom: 14px; }
.filter-panel form { display: grid; gap: 10px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.filter-grid p { display: grid; gap: 5px; margin: 0; }
.date-filter-disclosure {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.date-filter-disclosure > summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink);
  font-weight: 750;
}
.date-filter-disclosure > summary:focus-visible {
  border-radius: 4px;
  outline: 3px solid #5eead455;
  outline-offset: 3px;
}
.date-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.date-filter-grid p { display: grid; gap: 5px; margin: 0; }
.date-raw-value { color: var(--danger); font-size: .88rem; overflow-wrap: anywhere; }
.record-summary { margin: 14px 0 10px; color: var(--muted); }

.operation-groups,
.record-list,
.inventory-customers { display: grid; gap: 14px; }

.operation-customer,
.inventory-customer {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 18px;
}

.operation-customer > h2,
.inventory-customer > h3 { margin-bottom: 12px; }

.operation-order,
.inventory-order {
  margin-top: 12px;
  border-left: 3px solid #b9ded8;
  padding-left: 14px;
}

.operation-order > h3,
.inventory-order > h4 { margin-bottom: 10px; }

.operation-factory,
.inventory-factory {
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
}

.operation-factory + .operation-factory,
.inventory-factory + .inventory-factory { margin-top: 12px; }
.operation-factory > h4 { margin-bottom: 10px; color: var(--muted); }

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

.focused-record {
  border-color: #62b9aa;
  box-shadow: 0 0 0 3px #0f766e1f;
}

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

.shipment-products .line:first-child { margin-top: 10px; }

.stack p,
.inline-form p {
  display: grid;
  gap: 5px;
}

.form-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.detail-grid div { padding: 7px 0; }
.detail-grid dt { color: var(--muted); font-weight: 700; }
.detail-grid dd { margin: 3px 0; }
.delete-control { display: none; }
label { font-weight: 700; }

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #b8c4cf;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  font: inherit;
}

textarea { min-height: 92px; }
input[type="checkbox"] { width: auto; min-height: auto; }
input[type="file"] { min-height: 42px; padding: 6px; }

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #5eead455;
  outline-offset: 2px;
}

button,
.button {
  display: inline-block;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
}

.primary { background: var(--action); color: #fff; }
.secondary { border: 1px solid #c7d1da; background: #eef2f5; color: var(--ink); }
.danger { border: 1px solid #d9aaa5; background: #f8e5e2; color: var(--danger); }

.primary:hover { background: var(--action-hover); }
.secondary:hover { background: #dfe6eb; }
.danger:hover { background: #f1d3cf; }
.primary:active,
.secondary:active,
.danger:active { transform: translateY(1px); }

button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .48;
  filter: grayscale(.35);
}

.upload-action { justify-self: start; min-width: 180px; }

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

.notice,
.message,
.serial-preview {
  border: 1px solid #ead58b;
  border-radius: 8px;
  background: #fff8df;
  padding: 10px 12px;
}

.serial-preview {
  overflow-wrap: anywhere;
  border-color: var(--line);
  background: #f5faf8;
}

.error-text,
.errorlist { color: var(--danger); }
.errorlist { margin: 4px 0; padding-left: 20px; }
.message.success { border-color: #9bd0ae; background: #e8f6ed; }
.message.error { border-color: #e0a49d; background: #f8e5e2; }

.operation-feedback {
  min-height: 1.5em;
  margin: 8px 0;
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--muted);
}
.operation-feedback:empty { display: none; }
.operation-feedback.progress { background: #eff6ff; color: #1d4ed8; }
.operation-feedback.success { background: #e8f6ed; color: #166534; }
.operation-feedback.error { background: #f8e5e2; color: var(--danger); }

.order-line-allocation,
.factory-inventory-contract {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.order-line-allocation:first-of-type,
.factory-inventory-contract:first-of-type { border-top: 0; padding-top: 0; }
.allocation-links { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; }

.inspection-mode-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
}
.inspection-mode-picker legend { font-weight: 800; }
.inspection-mode-picker label {
  display: flex;
  min-height: 44px;
  flex: 1 1 250px;
  align-items: flex-start;
  gap: 9px;
  border-radius: 7px;
  padding: 9px 10px;
  cursor: pointer;
  line-height: 1.45;
}
.inspection-mode-picker label:hover { background: var(--brand-soft); }
.inspection-mode-picker input[type="radio"] {
  width: 17px;
  height: 17px;
  min-height: 0;
  flex: 0 0 17px;
  margin: 2px 0 0;
  padding: 0;
}
.inspection-device-groups,
.individual-inspection-list,
.customer-product-groups { display: grid; gap: 12px; }
.inspection-device-group,
.individual-inspection-row,
.customer-product-group,
.inventory-product-disclosure {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  padding: 12px;
}
.inspection-device-group legend { max-width: 100%; padding: 0 5px; overflow-wrap: anywhere; }
.device-choice { display: block; margin-top: 8px; overflow-wrap: anywhere; }
.group-selection-actions { justify-content: flex-start; margin: 5px 0 8px; }
.selected-serials { color: var(--muted); overflow-wrap: anywhere; }
.individual-inspection-row { display: grid; gap: 8px; }
.individual-inspection-row p { margin: 0; }
.individual-inspection-row[data-submission-state="submitting"],
.individual-inspection-row[data-submission-state="uncertain"] {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px #dbeafe;
}
.individual-inspection-row[data-submission-state="success"] { border-color: #86c99b; }
.inspection-submit-guard { border: 1px solid #e0a49d; border-radius: 9px; padding: 10px; }
.inspection-submit-guard .operation-feedback { margin-top: 0; }
.submitted-device-choice { color: var(--muted); text-decoration: line-through; }
.save-action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.save-action-row .operation-feedback { flex: 1 1 240px; margin: 0; }

.inventory-product-disclosure > summary,
.customer-product-group > summary,
.shipment-product-disclosure > summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.inventory-product-disclosure[open] > summary,
.customer-product-group[open] > summary,
.shipment-product-disclosure[open] > summary { margin-bottom: 10px; }
.device-list { margin: 0; padding-left: 20px; }
.customer-product-devices { display: grid; gap: 8px; }
.customer-device-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .4fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.customer-device-card span { min-width: 0; overflow-wrap: anywhere; }
.customer-device-card strong { display: block; color: var(--muted); font-size: .82rem; }
.quality-group-links { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.shipment-product-disclosure { border-top: 1px solid var(--line); padding: 10px 0; }
.device-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.table-wrap { overflow: auto; }
table { width: 100%; min-width: 640px; border-collapse: collapse; }
th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.inline-form {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.shipment-files,
.client-files {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.client-file-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 10px 14px;
}

.client-file-row > strong { white-space: nowrap; }

.shipment-image-form {
  display: grid;
  gap: 12px;
}

.file-upload-row {
  display: grid;
  grid-template-columns: 170px minmax(240px, 1fr) minmax(220px, 1fr) minmax(210px, .8fr);
  grid-template-areas: "kind picker view replace";
  min-width: 0;
  align-items: start;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.file-upload-row.readonly {
  grid-template-columns: 190px minmax(0, 1fr);
  grid-template-areas: "kind view";
}

.file-kind-state { grid-area: kind; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-top: 25px; }
.file-upload-row.readonly .file-kind-state { padding-top: 0; }
.file-picker { grid-area: picker; display: grid; min-width: 0; gap: 4px; }
.file-view { grid-area: view; min-width: 0; overflow-wrap: anywhere; }
.replace-choice { grid-area: replace; min-width: 0; }
.file-picker label,
.replace-choice label { color: var(--muted); font-size: .82rem; }
.upload-state { white-space: nowrap; font-weight: 700; }
.pending-file-preview { margin-top: 5px; color: var(--muted); font-size: .88rem; }
.file-list.compact { padding-left: 18px; }
.file-list.compact li { margin-bottom: 4px; }
.compact-notice { display: block; margin-top: 6px; }
.handover-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.shipment-logistics {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.file-list {
  min-width: 0;
  margin: 0;
  padding-left: 20px;
}

.file-list li {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.file-disclosure {
  min-width: 0;
}

.file-disclosure > summary {
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.file-disclosure > summary:hover {
  color: var(--primary);
}

.file-disclosure > summary:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .3);
  outline-offset: 3px;
  border-radius: 3px;
}

.file-disclosure[open] > summary {
  margin-bottom: 8px;
}

.file-availability {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .86rem;
  overflow-wrap: anywhere;
}

.compact-empty {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.client-file-row > .file-disclosure,
.client-file-row > .file-availability {
  grid-column: 1 / -1;
}

.file-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.file-association {
  display: block;
  color: var(--muted);
  font-size: .86rem;
  overflow-wrap: anywhere;
}

.pending-file-list,
.archive-image-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.pending-file-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  text-decoration: underline;
}

.danger-text { color: #9f2d2d; }

.archive-filter,
.delete-confirm,
.image-archive-panel .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.archive-filter { margin: 0 0 18px; }
.order-management { display: grid; gap: 12px; }
.delete-confirm { padding-top: 12px; border-top: 1px solid var(--line); }

.image-archive-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--page-bg);
}

.image-archive-panel h4,
.image-archive-panel p { margin: 0; }
.archive-image-list label,
.archive-image-list .file-name { overflow-wrap: anywhere; }

.image-purge-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #c9a3a3;
  border-radius: 8px;
  background: #fff8f8;
}

.image-purge-panel h5,
.image-purge-panel p { margin: 0; }
.purge-confirm-form { display: grid; gap: 10px; max-width: 720px; }
.purge-confirm-form label { display: flex; align-items: flex-start; gap: 8px; }
.purge-confirm-form input[type="checkbox"] { margin-top: 3px; flex: 0 0 auto; }
.purge-status { display: block; color: var(--muted); overflow-wrap: anywhere; }
.purge-pending { border-color: #c79839; background: #fffbeb; }
.purge-complete { border-color: var(--line); background: #f8fafc; }

.customer-inventory-orders {
  display: grid;
  gap: 18px;
}

.party-directory-search {
  display: grid;
  grid-template-columns: minmax(260px, 620px) auto;
  align-items: end;
  gap: 16px;
}

.party-directory-search p { margin: 0; }

.party-directory-grid {
  display: grid;
  gap: 12px;
}

.party-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin: 0;
}

.party-record-focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px #0f766e1c;
}

.party-record-fields {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(180px, 1.2fr) minmax(220px, 1.4fr);
  gap: 18px;
  min-width: 0;
}

.party-record-fields > div,
.party-account-field,
.party-account-list,
.party-account-list li {
  min-width: 0;
}

.party-record .field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.party-record strong,
.party-record span { overflow-wrap: anywhere; }

.party-account-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.party-account-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.customer-inventory-order {
  display: grid;
  gap: 14px;
}

.customer-inventory-order h2,
.customer-inventory-order h3,
.customer-inventory-order h4,
.customer-inventory-order p { margin-top: 0; }

.customer-inventory-order-head h2 { margin-bottom: 0; }

.customer-inventory-device-table table {
  min-width: 0;
  table-layout: fixed;
}

.customer-inventory-device-table th,
.customer-inventory-device-table td {
  min-width: 0;
  overflow-wrap: anywhere;
}

.customer-inventory-quality {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.customer-inventory-quality > h3 { margin-bottom: 0; }

.customer-inventory-quality-group,
.customer-inventory-no-files {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  padding: 12px;
}

.customer-inventory-quality-group { scroll-margin-top: 76px; }
.customer-inventory-quality-disclosure > summary {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.customer-inventory-quality-disclosure > summary span { min-width: 0; }
.customer-inventory-quality-disclosure > summary span:last-child {
  color: var(--muted);
  font-size: .9rem;
  text-align: right;
}
.customer-inventory-quality-disclosure[open] > summary { margin-bottom: 10px; }
.customer-inventory-quality-content { min-width: 0; }
.customer-inventory-quality-group > .file-availability { margin: 8px 0 0; }
.customer-product-content { display: grid; gap: 14px; margin-top: 10px; }
.customer-product-quality {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.customer-product-quality-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.customer-product-quality-disclosure > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.customer-product-quality-disclosure[open] > summary { margin-bottom: 10px; }
.shared-quality-note { color: var(--muted); font-weight: 650; }
.disclosure-state::before { content: "Expand"; color: var(--brand); font-size: .82rem; font-weight: 750; }
details[open] > summary .disclosure-state::before { content: "Collapse"; }
.customer-product-group > summary:focus-visible,
.customer-product-quality-disclosure > summary:focus-visible {
  border-radius: 5px;
  outline: 3px solid #5eead455;
  outline-offset: 3px;
}
.customer-inventory-applies-label { margin-bottom: 6px; color: var(--muted); font-weight: 700; }
.customer-inventory-applicable-devices,
.customer-inventory-no-files ul {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  padding-left: 20px;
}

.customer-inventory-applicable-devices li,
.customer-inventory-no-files li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.customer-inventory-applicable-devices li span,
.customer-inventory-no-files li span { display: block; }
.customer-inventory-applicable-devices li span + span,
.customer-inventory-no-files li span + span { color: var(--muted); font-size: .88rem; }
.customer-inventory-pdf-note { margin-bottom: 0; }

[hidden] { display: none !important; }

@media (max-width: 1199px) {
  .file-upload-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "kind"
      "picker"
      "view"
      "replace";
    gap: 8px;
  }

  .file-kind-state {
    padding-top: 0;
  }

  .file-upload-row.readonly {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "kind" "view";
  }

  .file-picker input[type="file"],
  .replace-choice select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .file-view,
  .file-view li,
  .file-name {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 760px) {
  body { font-size: 15px; }

  .menu-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #ffffff2b;
    background: var(--sidebar);
    color: #fff;
  }

  .sidebar {
    width: min(300px, 86vw);
    padding-top: 68px;
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .16s ease, visibility .16s;
  }

  .nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .app-main.with-sidebar { margin-left: 0; }

  .container {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .page-toolbar {
    min-height: 60px;
    padding: 8px 10px 8px 150px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 16px;
  }

  h1 { font-size: 24px; }

  .panel,
  .card,
  .allocation-row,
  .line-form {
    padding: 15px;
  }

  .actions { justify-content: flex-start; }
  .overview-search,
  .overview-totals,
  .customer-overview-card dl { grid-template-columns: 1fr; }
  .overview-search label { grid-column: auto; }
  .customer-overview-grid { grid-template-columns: 1fr; }
  .customer-overview-card .button { width: 100%; text-align: center; }
  .pending-shipment-guidance .section-head { align-items: flex-start; }
  .party-directory-search,
  .party-record,
  .party-record-fields { grid-template-columns: 1fr; }
  .party-record-actions .button { width: 100%; text-align: center; }
  .inspection-mode-picker { display: grid; gap: 6px; }
  .inspection-mode-picker label { width: 100%; min-width: 0; }
  .group-selection-actions .secondary { width: auto; }
  .inventory-product-disclosure > summary,
  .customer-product-group > summary,
  .shipment-product-disclosure > summary { display: grid; gap: 4px; }
  .customer-device-card { grid-template-columns: 1fr; }
  .form-grid,
  .detail-grid,
  .filter-grid { grid-template-columns: 1fr; }
  .date-filter-grid { grid-template-columns: 1fr; }
  table { min-width: 560px; }

  .progress-table { min-width: 0; }
  .progress-table thead { display: none; }
  .progress-table tbody,
  .progress-table tr,
  .progress-table td { display: block; width: 100%; }
  .progress-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
  }
  .progress-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 7px 0;
    text-align: right;
  }
  .progress-table td:last-child { border-bottom: 0; }
  .progress-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    text-align: left;
  }

  .customer-inventory-device-table { overflow: visible; }
  .customer-inventory-device-table table,
  .customer-inventory-device-table tbody,
  .customer-inventory-device-table tr,
  .customer-inventory-device-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .customer-inventory-device-table thead { display: none; }
  .customer-inventory-device-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
  }
  .customer-inventory-device-table tr:last-child { margin-bottom: 0; }
  .customer-inventory-device-table td {
    display: grid;
    grid-template-columns: minmax(108px, .42fr) minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line);
    padding: 7px 0;
    overflow-wrap: anywhere;
  }
  .customer-inventory-device-table td:last-child { border-bottom: 0; }
  .customer-inventory-device-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  .customer-inventory-quality-group,
  .customer-inventory-no-files { padding: 10px; }
  .customer-inventory-quality-disclosure > summary { display: grid; gap: 3px; }
  .customer-inventory-quality-disclosure > summary span:last-child { text-align: left; }
  .customer-product-quality-disclosure > summary { grid-template-columns: 1fr; gap: 3px; }
  .customer-product-quality-group { padding: 9px 10px; }

  .file-upload-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "kind"
      "picker"
      "view"
      "replace";
    gap: 8px;
  }

  .file-kind-state {
    display: flex;
    padding-top: 0;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }

  .file-upload-row.readonly {
    grid-template-columns: 1fr;
    grid-template-areas: "kind" "view";
  }

  .upload-action { width: 100%; }

  .client-file-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .pending-file-list li,
  .delete-confirm { align-items: stretch; flex-direction: column; }

  .status-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head { align-items: flex-start; }
  .operation-customer,
  .inventory-customer { padding: 14px; }
  .operation-order,
  .inventory-order { padding-left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Business summaries: readable status text accompanies each color. */
.status-confirmed { color: #14532d; background: #dcfce7; border: 1px solid #86c99e; }
.status-pending { color: #713f12; background: #fef3c7; border: 1px solid #e8c65b; }
.status-returned { color: #881337; background: #ffe4e6; border: 1px solid #f1a9b5; }
.record-time { display: block; color: #53657a; font-size: .85rem; font-weight: 400; margin: .45rem 0; overflow-wrap: anywhere; }
.order-milestones { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .65rem; margin: .85rem 0; }
.order-milestones div { min-width: 0; }
.order-milestones dt { color: #53657a; font-size: .8rem; }
.order-milestones dd { margin: .2rem 0 0; font-size: .85rem; overflow-wrap: anywhere; }
.order-milestones small { display: block; color: #53657a; }
.customer-overview-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.customer-overview-card { scroll-margin-top: 80px; }
.customer-order-previews, .customer-delivery-products { margin: .8rem 0; }
.customer-order-preview { background: #f7f9fb; border: 1px solid var(--border, #d8e1eb); border-radius: 8px; padding: .7rem; margin-bottom: .65rem; min-width: 0; }
.product-quantity-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .35rem 1rem; padding: .45rem 0; border-bottom: 1px solid #e3e9ef; font-size: .9rem; }
.product-quantity-row span { min-width: 0; overflow-wrap: anywhere; }
.product-quantity-row span:last-child { font-weight: 600; }
.shipment-order-disclosure { min-width: 0; margin-top: 1rem; scroll-margin-top: 80px; }
.shipment-order-disclosure > summary { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; cursor: pointer; padding: .8rem; background: #f7f9fb; border: 1px solid #d8e1eb; border-radius: 8px; list-style: none; }
.shipment-order-disclosure > summary::-webkit-details-marker { display: none; }
.shipment-order-disclosure > summary > span:first-child { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.shipment-order-disclosure .task-badge { padding: 3px 7px; border-radius: 999px; color: #fff; background: #9f1239; font-size: .82rem; }
.shipment-order-disclosure > summary .disclosure-label::after { content: "展开订单"; color: #006d77; font-size: .85rem; }
.shipment-order-disclosure[open] > summary .disclosure-label::after { content: "收起订单"; }
.shipment-order-content { padding-top: .5rem; }
@media (max-width: 900px) {
  .customer-orders-table-wrap { overflow: visible; }
  .customer-orders-table,
  .customer-orders-table tbody,
  .customer-orders-table tr,
  .customer-orders-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .customer-orders-table thead { display: none; }
  .customer-orders-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
  }
  .customer-orders-table td {
    display: grid;
    grid-template-columns: minmax(96px, .34fr) minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
  }
  .customer-orders-table td:last-child { border-bottom: 0; }
  .customer-orders-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }
  .customer-orders-table .customer-orders-empty td { display: block; }
  .customer-orders-table .customer-orders-empty td::before { content: none; }
}
@media (max-width: 600px) {
  .overview-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-overview-card > dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .customer-overview-card > dl dt { overflow-wrap: anywhere; font-size: .8rem; }
  .shipment-scope-summary { grid-template-columns: 1fr; }
  .shipment-order-disclosure { margin-left: 0; padding-left: .5rem; }
}
