:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1d232a;
  --muted: #68717d;
  --line: #dce1e7;
  --accent: #0d766e;
  --accent-strong: #095c56;
  --warn: #b42318;
  --amber: #b76e00;
  --ok: #207a3f;
  --soft: #eef7f5;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.button-link:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: #eef1f4;
  color: var(--ink);
}

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

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

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

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

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e8f4f1, #f5f6f8 60%, #f7f0e6);
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 48px rgba(27, 37, 49, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand img {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(13, 118, 110, 0.18);
  flex: 0 0 auto;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

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

.hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  background: #15201f;
  color: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand img {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.72);
}

.brand strong {
  line-height: 1.35;
}

.brand span {
  color: #bdd0cc;
  font-size: 13px;
}

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

nav button {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: #dce7e4;
  border: 1px solid transparent;
}

nav button.active {
  background: #233331;
  border-color: #34504c;
}

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

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

.topbar > div:last-child {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-switcher {
  display: grid;
  gap: 4px;
  min-width: 150px;
}

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

.account-switcher select {
  min-height: 34px;
  width: 180px;
}

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

.metric,
.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 6px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 16px;
}

.dashboard-layout {
  grid-template-columns: minmax(0, 1fr) 300px;
}

.dashboard-layout > .panel:first-child {
  min-width: 0;
}

.dashboard-layout > .panel:last-child {
  min-width: 0;
}

.dashboard-layout > .panel:last-child .card {
  padding: 10px;
}

.dashboard-order-table {
  min-width: 1120px;
}

.dashboard-order-table th:nth-child(6),
.dashboard-order-table td:nth-child(6),
.dashboard-order-table th:nth-child(7),
.dashboard-order-table td:nth-child(7) {
  width: 92px;
}

.order-detail-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.order-list-panel {
  position: sticky;
  top: 16px;
}

.order-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding-right: 4px;
}

.order-select {
  display: grid;
  gap: 5px;
  min-height: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.order-select:hover,
.order-select.active {
  background: var(--soft);
  border-color: #9fc9c2;
  color: var(--ink);
}

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

.order-detail-main {
  min-width: 0;
}

.order-line-table {
  min-width: 760px;
}

.style-matrix-list {
  display: grid;
  gap: 10px;
}

.style-matrix-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

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

.style-matrix-head h4 {
  margin: 0 0 4px;
  font-size: 17px;
}

.matrix-save-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.mark-style-shipped-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mark-style-shipped-form input {
  width: 220px;
}

.matrix-fill-tool {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.matrix-fill-tool label {
  min-width: 140px;
}

.matrix-fill-tool input {
  width: 140px;
}

.matrix-fill-tool button {
  white-space: nowrap;
}

.order-matrix-table {
  table-layout: fixed;
  width: 100%;
}

.order-matrix-table th,
.order-matrix-table td {
  text-align: center;
  vertical-align: middle;
  height: 36px;
  padding: 4px 6px;
}

.order-matrix-table .matrix-color-col {
  width: 86px;
}

.order-matrix-table .matrix-total-col {
  width: 82px;
}

.order-matrix-table .matrix-remark-col {
  width: 120px;
  word-break: break-word;
}

.order-detail-matrix-block .order-matrix-table {
  table-layout: fixed;
}

.order-detail-matrix-block col.matrix-color-col {
  width: 92px;
}

.order-detail-matrix-block col.matrix-size-col {
  width: 72px;
}

.order-detail-matrix-block col.matrix-total-col {
  width: 76px;
}

.order-detail-matrix-block col.matrix-remark-col {
  width: 300px;
}

.order-detail-matrix-block .order-matrix-table .matrix-remark-col {
  text-align: left;
  line-height: 1.45;
  word-break: normal;
  overflow-wrap: anywhere;
}

.order-detail-matrix-block .order-matrix-table th,
.order-detail-matrix-block .order-matrix-table td {
  height: 34px;
}

.matrix-qty-input {
  width: 100%;
  min-width: 0;
  text-align: center;
  border: 1px solid transparent;
  background: transparent;
  min-height: 28px;
  padding: 3px 6px;
  border-radius: 6px;
  box-sizing: border-box;
  appearance: textfield;
}

.matrix-qty-input::-webkit-outer-spin-button,
.matrix-qty-input::-webkit-inner-spin-button {
  margin: 0;
}

.matrix-qty-input:focus {
  border-color: var(--brand);
  background: #fff;
  outline: 2px solid rgba(0, 128, 112, 0.14);
}

.matrix-qty-input.changed {
  border-color: var(--warn);
  background: #fff8e6;
  font-weight: 700;
}

.matrix-empty {
  color: var(--muted);
  background: #f8fafc;
}

.matrix-total-row th {
  background: #f8fafc;
}

.entry-matrix-form {
  display: grid;
  gap: 10px;
}

.order-append-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.order-append-setup {
  margin-top: 4px;
}

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

.entry-matrix-setup {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.entry-matrix-setup label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-weight: 600;
}

.entry-matrix-setup textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
}

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

.entry-row-remark {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 4px 8px;
  box-sizing: border-box;
}

.entry-pending-table {
  min-width: 920px;
}

.entry-pending-table th,
.entry-pending-table td {
  vertical-align: middle;
}

.merch-todo-card {
  gap: 12px;
}

.merch-todo-table {
  min-width: 860px;
}

.merch-todo-table th,
.merch-todo-table td {
  vertical-align: middle;
}

.merch-detail-toolbar {
  margin: 8px 0 12px;
}

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

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

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

.merch-factory-trial-form {
  margin-top: 8px;
}

.merch-workshop-progress-form {
  margin-top: 8px;
}

.merch-workshop-progress-form label,
.merch-factory-trial-form label {
  flex: 1 1 360px;
}

.merch-loss-preview {
  font-weight: 700;
}

.loss-ok {
  color: var(--ok);
}

.loss-over {
  color: var(--warn);
}

.details-body {
  margin-top: 16px;
}

.standard-workbench {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.standard-list-panel {
  position: sticky;
  top: 16px;
}

.standard-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.standard-style-select {
  display: grid;
  gap: 5px;
  min-height: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.standard-style-select:hover,
.standard-style-select.active {
  background: var(--soft);
  border-color: #9fc9c2;
  color: var(--ink);
}

.standard-style-select span {
  color: var(--muted);
  font-size: 12px;
}

.standard-detail {
  min-width: 0;
}

.standard-table {
  display: grid;
  gap: 10px;
}

.standard-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 180px) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.standard-row > div {
  display: grid;
  gap: 5px;
}

.standard-row strong {
  min-height: 34px;
  display: flex;
  align-items: center;
}

.readonly-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.readonly-grid div {
  display: grid;
  gap: 6px;
}

.readonly-grid strong {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.boss-summary-grid {
  grid-template-columns: repeat(7, minmax(105px, 1fr));
}

.boss-style-card {
  gap: 14px;
  margin-top: 16px;
}

.boss-style-summary-table {
  min-width: 1080px;
}

.boss-style-row {
  cursor: pointer;
}

.boss-style-row:hover,
.boss-style-row.active {
  background: var(--soft);
}

.boss-style-summary-table td {
  vertical-align: middle;
}

.boss-subsection {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.boss-subsection h4 {
  margin: 0;
  font-size: 15px;
}

.boss-progress-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.timeline-node {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  min-height: 128px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.timeline-node.done {
  background: #f2fbf5;
  border-color: #b8dec7;
}

.timeline-node.active {
  background: #fff8e8;
  border-color: #f1d28a;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: 4px;
  background: #b7c0c9;
}

.timeline-node.done .timeline-dot {
  background: var(--ok);
}

.timeline-node.active .timeline-dot {
  background: var(--amber);
}

.timeline-body {
  display: grid;
  gap: 6px;
  align-content: start;
}

.timeline-body p {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}

.purchase-progress-readonly .card-row {
  align-items: flex-start;
}

.boss-progress-table {
  min-width: 840px;
}

.boss-note-table {
  min-width: 980px;
}

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

.compact-actions {
  flex-wrap: nowrap;
  gap: 4px;
}

.purchase-batch-card {
  display: grid;
  gap: 10px;
}

.purchase-step-list {
  display: grid;
  gap: 8px;
}

.purchase-step-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) auto minmax(140px, auto);
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.purchase-step-form.disabled-step {
  background: #f1f3f5;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #8b949e;
  cursor: not-allowed;
  opacity: 0.72;
  padding: 8px;
}

.purchase-step-form.disabled-step label,
.purchase-step-form.disabled-step span,
.purchase-step-form.disabled-step input,
.purchase-step-form.disabled-step button {
  color: #8b949e;
  cursor: not-allowed;
}

.purchase-step-form.disabled-step input,
.purchase-step-form.disabled-step button {
  background: #e4e7eb;
  border-color: #d0d6dd;
}

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

.merch-receipt summary {
  cursor: pointer;
  font-weight: 700;
}

.receipt-matrix-block {
  margin-top: 8px;
}

.receipt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 12px;
  align-items: stretch;
}

.receipt-layout > .style-matrix-block {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.receipt-layout > .style-matrix-block .table-wrap {
  flex: 1 1 auto;
}

.receipt-matrix-block .order-matrix-table {
  width: auto;
  min-width: 0;
  table-layout: fixed;
}

.receipt-matrix-block col.matrix-color-col {
  width: 86px;
}

.receipt-matrix-block col.matrix-size-col {
  width: 96px;
}

.receipt-matrix-block col.matrix-total-col {
  width: 82px;
}

.receipt-matrix-block col.matrix-remark-col {
  width: 128px;
}

.receipt-matrix-block .order-matrix-table th,
.receipt-matrix-block .order-matrix-table td {
  height: 34px;
  padding: 4px 6px;
}

.receipt-matrix-block .receipt-qty {
  width: 100%;
}

.receipt-calc-block .order-matrix-table {
  width: 100%;
  table-layout: fixed;
}

.receipt-balance-cell,
.receipt-balance-row-total,
.receipt-balance-grand-total,
.receipt-balance-size-total {
  font-weight: 700;
}

.matrix-remark-input {
  width: 100%;
  min-width: 0;
}

.receipt-date-row {
  display: flex;
  justify-content: flex-start;
}

.receipt-date-field {
  display: grid;
  gap: 6px;
  width: 220px;
  flex: 0 0 220px;
}

.receipt-date-field input[type="date"] {
  width: 100%;
}

.inventory-negative {
  background: #fff0ee;
}

.inventory-negative strong {
  color: var(--warn);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkline input {
  width: auto;
  min-height: auto;
}

.panel {
  padding: 12px;
  overflow: hidden;
}

.panel + .panel {
  margin-top: 12px;
}

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

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

.purchase-search-form {
  display: flex;
  gap: 8px;
  align-items: end;
}

.purchase-search-form .search-field {
  display: grid;
  gap: 4px;
}

.purchase-search-form input {
  width: 220px;
}

.purchase-search-form select {
  min-width: 116px;
}

.purchase-search-form button {
  min-height: 35px;
  white-space: nowrap;
}

#merchTodoSearch {
  width: 260px;
}

#merchTodoSearchBtn {
  align-self: end;
}

.order-summary-toolbar input {
  width: min(360px, 100%);
}

.order-summary-toolbar select {
  width: 128px;
}

.order-summary-table {
  table-layout: fixed;
  min-width: 1080px;
}

.order-summary-table th,
.order-summary-table td {
  vertical-align: middle;
}

.order-summary-table .style-nos-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.mini-form label {
  min-width: 120px;
}

.mini-form button {
  min-height: 34px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px 10px;
  align-items: end;
}

.grid-form.order-edit-form {
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
}

.stack {
  display: grid;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
}

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

.purchase-batch-table {
  table-layout: fixed;
  min-width: 920px;
}

.purchase-batch-table th:first-child,
.purchase-batch-table td:first-child {
  width: 120px;
}

.purchase-batch-table th:nth-child(2),
.purchase-batch-table td:nth-child(2) {
  width: 34%;
}

.purchase-batch-table th:nth-child(3),
.purchase-batch-table td:nth-child(3),
.purchase-batch-table th:nth-child(4),
.purchase-batch-table td:nth-child(4),
.purchase-batch-table th:nth-child(5),
.purchase-batch-table td:nth-child(5),
.purchase-batch-table th:nth-child(6),
.purchase-batch-table td:nth-child(6),
.purchase-batch-table th:nth-child(7),
.purchase-batch-table td:nth-child(7) {
  width: 110px;
}

.purchase-batch-table button {
  white-space: nowrap;
}

.purchase-batch-table tr.purchase-batch-completed {
  color: var(--muted);
  background: #f4f6f8;
}

.purchase-batch-table tr.purchase-batch-completed strong {
  color: #667085;
}

.purchase-batch-table tr.purchase-batch-completed button {
  background: #eef2f6;
  border-color: #d8dee6;
  color: #475467;
}

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

th {
  color: var(--muted);
  background: #fafbfc;
  position: sticky;
  top: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf1f5;
  color: #34404b;
  font-size: 12px;
  white-space: nowrap;
}

.badge.warn {
  background: #ffe9e6;
  color: var(--warn);
}

.badge.ok {
  background: #e7f5ec;
  color: var(--ok);
}

.badge.amber {
  background: #fff2d6;
  color: var(--amber);
}

.age-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.age-badge.ok {
  background: #e7f5ec;
  color: var(--ok);
}

.age-badge.amber {
  background: #fff2d6;
  color: var(--amber);
}

.age-badge.danger {
  background: #ffe9e6;
  color: var(--warn);
}

.age-badge.neutral {
  background: #edf1f5;
  color: var(--muted);
}

.style-summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-width: 300px;
}

.style-summary-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 86px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.style-summary-badge.done {
  background: #e7f5ec;
  color: var(--ok);
}

.style-summary-badge.pending {
  background: #fff2d6;
  color: var(--amber);
}

.style-summary-badge.more {
  background: #edf1f5;
  color: var(--muted);
}

.progress {
  width: 100%;
  height: 8px;
  background: #e8edf1;
  border-radius: 999px;
  overflow: hidden;
  min-width: 120px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.cards {
  display: grid;
  gap: 12px;
}

.card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.factory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  align-items: start;
}

.factory-card {
  display: grid;
  gap: 10px;
  min-height: 170px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.factory-edit {
  display: grid;
  gap: 8px;
}

.factory-edit input[name="name"] {
  font-weight: 700;
}

.factory-actions,
.factory-card-summary,
.factory-work-head,
.factory-order-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.factory-actions button {
  min-width: 64px;
}

.factory-card-summary {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
}

.factory-card-summary strong {
  color: var(--ink);
}

.factory-work-list {
  display: grid;
  gap: 8px;
}

.factory-work-item {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #e3e8ee;
  border-radius: 8px;
  background: #fbfcfd;
}

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

.factory-work-head span {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.factory-order-list {
  display: grid;
  gap: 4px;
}

.factory-order-line {
  min-height: 24px;
  padding: 3px 0;
  border-top: 1px solid #edf0f3;
  color: #34404b;
  font-size: 13px;
}

.factory-order-line:first-child {
  border-top: 0;
}

.factory-order-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.factory-order-line strong {
  flex: 0 0 auto;
}

.factory-empty {
  display: grid;
  place-items: center;
  min-height: 70px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 13px;
}

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

.tabs button {
  background: #eef1f4;
  color: var(--ink);
}

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

.merch-todo-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.merch-todo-section + .merch-todo-section {
  margin-top: 22px;
}

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

.sub-panel-head h4 {
  margin: 0;
}

.merch-external-allocation {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.external-factory-blocks {
  display: grid;
  gap: 14px;
}

.external-factory-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.external-allocation-table th,
.external-allocation-table td {
  text-align: center;
  vertical-align: middle;
}

.external-allocation-table td:first-child,
.external-allocation-table th:first-child {
  text-align: left;
}

.external-allocation-qty {
  width: 78px;
  margin: 0 auto;
}

.external-cell-line {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 110px;
}

.external-cell-line + .external-cell-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.external-cell-line small {
  color: var(--muted);
}

.external-existing-summary {
  display: grid;
  gap: 8px;
}

.external-existing-factories {
  display: grid;
  gap: 12px;
}

.external-existing-factory {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.external-existing-matrix th,
.external-existing-matrix td,
.external-existing-edit-table th,
.external-existing-edit-table td {
  text-align: center;
  vertical-align: middle;
}

.external-existing-matrix small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.external-existing-edit-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.external-line-remaining.loss-over {
  color: var(--warn);
  font-weight: 700;
}

.external-line-remaining.loss-ok {
  color: var(--ok);
  font-weight: 700;
}

.notice {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--accent-strong);
  margin-bottom: 12px;
}

.page-loading {
  min-height: 160px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-loading p {
  margin: 4px 0 0;
}

.loading-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(13, 118, 110, 0.28);
  animation: loadingPulse 1.1s ease-out infinite;
  flex: 0 0 auto;
}

@keyframes loadingPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(13, 118, 110, 0.28);
    transform: scale(0.92);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(13, 118, 110, 0);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(13, 118, 110, 0);
    transform: scale(0.92);
  }
}

.toast {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(27, 37, 49, 0.16);
  font-size: 14px;
}

.toast.ok {
  border-color: #b8dec7;
  color: var(--ok);
  background: #f2fbf5;
}

.toast.error {
  border-color: #ffc7c0;
  color: var(--warn);
  background: #fff5f4;
}

.error {
  background: #ffe9e6;
  color: var(--warn);
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

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

  .sidebar {
    position: static;
  }

  .login-brand {
    align-items: flex-start;
  }

  .receipt-layout,
  .metrics,
  .layout,
  .order-detail-layout,
  .standard-workbench,
  .readonly-grid,
  .standard-row,
  .grid-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .order-list-panel {
    position: static;
  }

  .standard-list-panel {
    position: static;
  }

  .order-list {
    max-height: none;
  }

  .standard-list {
    max-height: none;
  }
}
