:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #fafbfd;
  --text: #1f2937;
  --muted: #667085;
  --soft: #98a2b3;
  --line: #d8e0ea;
  --blue: #2563eb;
  --indigo: #4f63d7;
  --teal: #0f9f8e;
  --amber: #c47f16;
  --red: #d64545;
  --green-bg: #e9f8f5;
  --blue-bg: #eef4ff;
  --amber-bg: #fff4df;
  --red-bg: #fff0f0;
  --shadow: 0 10px 24px rgba(31, 41, 55, 0.045);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

.sync-status-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 140;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 780;
  line-height: 1.4;
}

.sync-status-toast.good {
  border-color: #a7e3da;
  color: #08756b;
  background: var(--green-bg);
}

.sync-status-toast.risk {
  border-color: #f0b4b4;
  color: #b83232;
  background: var(--red-bg);
}

.sync-status-toast.info {
  border-color: #b8c9ff;
  color: var(--blue);
  background: var(--blue-bg);
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(245, 247, 250, 0.94);
  backdrop-filter: blur(8px);
}

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

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.login-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.login-error,
.login-hint {
  margin: 0;
  font-size: 13px;
  font-weight: 760;
}

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

.login-hint {
  color: var(--muted);
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 298px;
  background: var(--bg);
}

body:not([data-view="dashboard"]) .app-shell {
  grid-template-columns: 238px minmax(0, 1fr);
}

body:not([data-view="dashboard"]) .rightbar {
  display: none;
}

.auth-locked .app-shell {
  display: none;
}

.sidebar,
.rightbar {
  background: var(--panel);
  border-color: var(--line);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
}

.rightbar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding: 22px 16px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  background: var(--indigo);
  font-size: 20px;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p,
.sidebar-note span,
.eyebrow,
.panel-head span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.nav {
  display: grid;
  gap: 5px;
  margin-top: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #526070;
  background: transparent;
  font-size: 14px;
  font-weight: 780;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 850;
}

.nav-item.active,
.nav-item:hover {
  color: var(--blue);
  background: var(--blue-bg);
}

.nav-item.active span,
.nav-item:hover span {
  color: var(--blue);
}

.sidebar-note {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 7px;
  background: var(--panel-2);
}

.sidebar-note strong {
  font-size: 13px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: -24px -24px 18px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(216, 224, 234, 0.78);
  background: rgba(245, 247, 250, 0.92);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  margin: 6px 0 0;
  font-size: 28px;
  line-height: 1.15;
}

.topbar-actions,
.record-actions,
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  display: grid;
  gap: 2px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  background: var(--panel);
}

.user-badge strong {
  font-size: 13px;
}

.user-badge small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ghost-button,
.primary-button,
.mini-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-button,
.primary-button {
  min-height: 38px;
  padding: 0 13px;
}

.primary-button {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.ghost-button:hover,
.mini-button:hover,
.chip:hover {
  border-color: #b7c4d8;
  background: #f8fbff;
}

.primary-button:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: #8fb0ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.danger,
.mini-button.danger {
  color: var(--red);
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.view {
  display: none;
  gap: 12px;
}

.view.active {
  display: grid;
}

#dashboard .content-grid {
  align-items: start;
}

#dashboard .panel.wide {
  grid-column: 1 / -1;
}

#batches.active,
#customers.active,
#inventory.active,
#after-sales.active,
#access.active {
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  align-items: start;
}

#batches > .panel:nth-child(3),
#customers > .panel:nth-child(3),
#inventory > .panel:nth-child(3),
#inventory > .panel:nth-child(4),
#access > .panel:nth-child(3),
#access > .panel:nth-child(4) {
  grid-column: 1 / -1;
}

#orders.active,
#order-create.active,
#production.active,
#reports.active {
  grid-template-columns: minmax(0, 1fr);
}

#order-create .panel,
#orders .order-manager-panel,
#production .panel,
#reports .panel {
  width: 100%;
}

#orderForm.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#order-create .size-field {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#customerList.record-grid,
#batchList.record-grid,
#orderList.record-grid,
#afterSaleList.record-grid,
#accountList.record-grid,
#followupDueList.record-grid {
  grid-template-columns: 1fr;
}

#productList.record-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

#orderList .record {
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: start;
}

#orderList .record.has-cost-risk {
  border-color: #ffc7c7;
  box-shadow: inset 3px 0 0 #dc2626, var(--shadow);
}

#orderList .order-thumb {
  grid-row: 1 / span 4;
  width: 96px;
  height: 96px;
}

#orderList .record-title,
#orderList .record-meta,
#orderList .pill {
  grid-column: 2;
}

#orderList .record-actions {
  grid-column: 3;
  grid-row: 1 / span 4;
  align-content: start;
  justify-content: flex-end;
  min-width: 120px;
}

#customerList .record,
#batchList .record,
#afterSaleList .record,
#accountList .record {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

#customerList .record-title,
#customerList .record-meta,
#batchList .record-title,
#batchList .record-meta,
#afterSaleList .record-title,
#afterSaleList .record-meta,
#accountList .record-title,
#accountList .record-meta {
  grid-column: 1;
}

#customerList .record-actions,
#batchList .record-actions,
#afterSaleList .record-actions,
#accountList .record-actions {
  grid-column: 2;
  grid-row: 1 / span 3;
  justify-content: flex-end;
  min-width: 104px;
}

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  overflow-x: auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  background: var(--panel);
  color: #475467;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.chip.active {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: #b7cbff;
}

.order-status-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.order-status-tabs .chip {
  cursor: pointer;
}

.channel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 4px 3px 10px;
  color: #475467;
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 820;
}

.channel-pill.active {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: #b7cbff;
}

.import-hint,
.import-result {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.5;
}

.import-result {
  min-height: 24px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-2);
}

.import-result.good {
  color: #08756b;
  background: var(--green-bg);
}

.import-result.warn {
  color: #9a5b08;
  background: var(--amber-bg);
}

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

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

.kpi {
  min-height: 112px;
  padding: 16px;
}

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

.kpi strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.compact-panel {
  margin-top: 14px;
  box-shadow: none;
}

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

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

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.compact-form {
  margin-bottom: 12px;
}

.form-grid label,
.toolbar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: var(--panel);
}

.form-grid textarea {
  min-height: 86px;
  padding: 10px;
  resize: vertical;
}

.field-hint {
  color: var(--soft);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.45;
}

.form-grid label.is-required input {
  border-color: #f3d59b;
  background: #fffaf0;
}

.form-grid label.is-required::after {
  content: "外采必填";
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  color: #9a5b08;
  background: #fff7e6;
  font-size: 11px;
  font-weight: 900;
}

.form-grid .hidden {
  display: none;
}

.span-2 {
  grid-column: span 2;
}

.size-field {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.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;
}

.image-paste-field {
  min-height: 72px;
  border: 1px dashed #b7c4d8;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  background: var(--panel-2);
  cursor: text;
}

.image-paste-field:focus,
.image-paste-field.dragging {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.image-paste-field.has-image {
  border-color: #55c8b7;
  background: #ecfbf8;
}

.image-paste-field strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 14px;
}

.image-paste-field span {
  font-size: 13px;
  font-weight: 760;
}

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

.check-row {
  display: flex !important;
  min-height: 40px;
  align-items: center;
  gap: 8px !important;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.compact-toolbar {
  margin-bottom: 12px;
}

.search-field {
  flex: 1 1 320px;
  max-width: 520px;
}

.date-filter-field {
  flex: 0 1 180px;
}

.compact-toolbar .ghost-button {
  min-height: 40px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

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

.record:hover,
tbody tr:hover td {
  background: #f8fbff;
}

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

.audit-row {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.audit-row div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.audit-row strong {
  font-size: 13px;
}

.audit-row span,
.audit-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.record.is-muted {
  opacity: 0.72;
  background: #f8fafc;
}

.edit-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid #b7cbff;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--blue);
  background: var(--blue-bg);
  font-size: 13px;
  font-weight: 800;
}

.edit-notice span {
  flex: 1;
  color: #475467;
}

.edit-notice.hidden {
  display: none;
}

.link-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.link-dialog {
  width: min(640px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(23, 32, 51, 0.24);
  padding: 18px;
}

.link-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.link-dialog h3 {
  margin: 0;
  font-size: 20px;
}

.link-dialog-status {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 800;
}

.link-copy-box {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.55;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.record-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
  min-width: 0;
}

.record-title span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.record-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-meta a {
  color: var(--blue);
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 850;
}

.pill.good,
.status.good {
  color: #08756b;
  background: var(--green-bg);
}

.pill.warn,
.status.warn {
  color: #9a5b08;
  background: var(--amber-bg);
}

.pill.risk,
.status.risk {
  color: #b83232;
  background: var(--red-bg);
}

.monitor-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.monitor-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.monitor-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.monitor-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  line-height: 1;
}

.order-monitor-table {
  min-width: 1040px;
}

.order-monitor-table td:first-child {
  min-width: 260px;
  white-space: normal;
}

.order-row.has-address-variance td {
  background: #fffaf0;
}

.order-row.has-address-variance td:first-child {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.order-row.needs-cost td {
  background: #fff5f5;
}

.order-row.needs-cost td:first-child {
  box-shadow: inset 3px 0 0 #dc2626;
}

.order-status-tabs .chip span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.order-status-tabs .chip.active span {
  color: var(--blue);
}

.production-order-table {
  min-width: 960px;
  table-layout: fixed;
}

.production-order-table th,
.production-order-table td {
  vertical-align: top;
  white-space: normal;
}

.production-order-table td {
  padding-top: 12px;
  padding-bottom: 12px;
}

.production-order-table th:nth-child(1),
.production-order-table td:nth-child(1) {
  width: 20%;
}

.production-order-table th:nth-child(2),
.production-order-table td:nth-child(2) {
  width: 22%;
}

.production-order-table th:nth-child(3),
.production-order-table td:nth-child(3) {
  width: 13%;
}

.production-order-table th:nth-child(4),
.production-order-table td:nth-child(4) {
  width: 15%;
}

.production-order-table th:nth-child(5),
.production-order-table td:nth-child(5) {
  width: 14%;
}

.production-order-table th:nth-child(6),
.production-order-table td:nth-child(6) {
  width: 16%;
}

.production-row.is-warn td {
  background: #fffaf0;
}

.production-row.needs-revision td:first-child {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.production-detail-row td {
  border-top: 1px dashed #e8bc72;
  background: var(--amber-bg);
}

.production-order-main {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.production-order-main strong,
.production-order-main span,
.production-copy strong,
.production-copy span,
.production-photo span,
.production-photo small {
  display: block;
}

.production-order-main strong,
.production-copy strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.production-order-main span,
.production-copy span,
.production-photo span,
.production-photo small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 740;
  white-space: normal;
  overflow-wrap: anywhere;
}

.production-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: none;
}

.production-copy a {
  color: var(--blue);
}

.production-photo-cell {
  display: grid;
  gap: 8px;
  min-width: 136px;
}

.production-photo {
  display: grid;
  gap: 5px;
}

.production-photo img {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel);
}

.production-photo.empty {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
  font-weight: 800;
}

.photo-history.compact {
  max-width: 180px;
}

.task-photo-zone-compact {
  width: 112px;
  min-height: 44px;
  padding: 6px 8px;
  place-items: start;
  text-align: left;
}

.task-photo-zone-compact strong {
  font-size: 12px;
}

.task-photo-zone-compact span {
  font-size: 11px;
}

.production-tracking-form {
  margin-top: 8px;
  min-width: 0;
}

.monitor-customer {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.monitor-customer span,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.monitor-customer a {
  color: var(--blue);
}

.monitor-customer-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.monitor-customer-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.multi-address-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1px solid #f3d59b;
  border-radius: 999px;
  padding: 2px 7px;
  color: #9a5b08;
  background: #fff7e6;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.order-alert-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: #475467;
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.order-alert-badge.risk,
.order-cost-warning {
  color: #b83232;
  font-weight: 900;
}

.order-alert-badge.risk {
  border-color: #ffc7c7;
  background: var(--red-bg);
}

.monitor-address {
  max-width: 380px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.monitor-address.is-variant {
  width: fit-content;
  max-width: min(420px, 100%);
  border: 1px solid #f3d59b;
  border-radius: 8px;
  padding: 5px 7px;
  color: #7c4705;
  background: #fff7e6;
}

.monitor-address-note,
.monitor-address-alt,
.order-address-warning {
  color: #9a5b08;
  font-weight: 850;
  white-space: normal;
  overflow-wrap: anywhere;
}

.empty-table {
  text-align: center;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 820;
}

td {
  background: var(--panel-2);
  color: #344054;
  font-weight: 760;
}

td:first-child {
  border-radius: 8px 0 0 8px;
}

td:last-child {
  border-radius: 0 8px 8px 0;
}

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

.stack-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.stack-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.mini-rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 13px;
  font-weight: 800;
}

.mini-rank-row small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.compact-metric {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.compact-metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
}

.compact-metric strong {
  font-size: 18px;
}

.bar,
.track {
  height: 8px;
  border-radius: 999px;
  background: #e7edf5;
  overflow: hidden;
}

.bar span,
.track span {
  display: block;
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.image-preview {
  min-height: 112px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--panel-2);
  overflow: hidden;
}

.image-preview img,
.product-thumb,
.order-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-thumb-wrap {
  height: 148px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.product-thumb-wrap.empty {
  display: grid;
  place-items: center;
  padding: 0;
}

.order-thumb {
  height: 120px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(230px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.lane {
  min-height: 180px;
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.lane h4 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
}

.lane h4 span {
  color: var(--muted);
}

.task-card {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
}

.task-card.is-warn {
  border-color: #f3d59b;
  background: #fffaf0;
}

.task-card.needs-revision {
  border-color: #ffc7c7;
}

.task-card-head {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
}

.task-card-head strong,
.task-card-head span {
  display: block;
}

.task-card-head span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
  font-weight: 720;
}

.task-order-thumb {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
}

.task-order-thumb.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.task-badges,
.photo-history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.actual-photo {
  display: grid;
  gap: 6px;
}

.actual-photo img {
  width: 100%;
  height: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.actual-photo span,
.history-dot {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.actual-photo .actual-photo-note {
  padding: 6px 8px;
  border-radius: 8px;
  color: #9a5b08;
  background: var(--amber-bg);
}

.actual-photo.empty {
  min-height: 64px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  place-items: center;
  color: var(--muted);
  background: var(--panel-2);
}

.history-dot {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--panel-2);
}

.history-dot.good {
  color: #08756b;
  background: var(--green-bg);
}

.history-dot.warn {
  color: #9a5b08;
  background: var(--amber-bg);
}

.task-photo-zone {
  min-height: 70px;
  border: 1px dashed #b7c4d8;
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 4px;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: var(--panel-2);
  cursor: pointer;
}

.task-photo-zone:focus,
.task-photo-zone.dragging {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.task-photo-zone strong {
  color: var(--text);
}

.task-photo-zone span {
  font-size: 12px;
  font-weight: 720;
}

.tracking-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.tracking-form input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: var(--panel);
  font-size: 13px;
}

.tracking-form .mini-button {
  width: 100%;
  min-height: 36px;
}

.revision-form {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid #f3d59b;
  border-radius: 8px;
  background: var(--amber-bg);
}

.revision-form label {
  display: grid;
  gap: 6px;
  color: #8a5208;
  font-size: 12px;
  font-weight: 800;
}

.revision-form textarea {
  width: 100%;
  min-height: 78px;
  border: 1px solid #e8bc72;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel);
  resize: vertical;
}

.form-error {
  min-height: 16px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

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

.rightbar h4 {
  margin: 0 0 13px;
  font-size: 18px;
}

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

.alert {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.alert strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.alert span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 720;
}

.alert.warn {
  border-color: #f3d59b;
  background: var(--amber-bg);
}

.alert.risk {
  border-color: #ffc7c7;
  background: var(--red-bg);
}

.alert.good {
  border-color: #bdece3;
  background: var(--green-bg);
}

.rank {
  display: grid;
  gap: 9px;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: #344054;
  font-size: 13px;
  font-weight: 790;
}

.rank-item strong {
  display: block;
  margin-bottom: 6px;
}

.rank-item b {
  color: var(--blue);
  font-size: 12px;
}

.num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-bg);
  font-size: 12px;
  font-weight: 900;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 18px 0;
}

/* Operational UI refresh: denser, clearer workbench surfaces. */
:root {
  --bg: #eef2f6;
  --panel-2: #f8fafc;
  --line: #ccd7e5;
  --shadow: 0 8px 18px rgba(24, 39, 75, 0.05);
}

body {
  min-width: 0;
  background:
    linear-gradient(180deg, #f7f9fc 0, #eef2f6 260px),
    var(--bg);
}

.app-shell {
  grid-template-columns: 224px minmax(0, 1fr) 288px;
}

body:not([data-view="dashboard"]) .app-shell {
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  padding: 18px 14px;
  background: #fbfcfe;
}

.rightbar {
  padding: 20px 14px;
  background: #fbfcfe;
}

.brand {
  min-height: 44px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  background: #0f9f8e;
  box-shadow: 0 8px 16px rgba(15, 159, 142, 0.16);
  font-size: 18px;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  font-size: 12px;
}

.nav {
  gap: 4px;
  margin-top: 18px;
}

.nav-item {
  position: relative;
  min-height: 38px;
  border: 1px solid transparent;
  padding: 0 10px 0 12px;
  color: #475467;
  font-size: 13px;
}

.nav-item::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}

.nav-item.active {
  border-color: #c7d7fe;
  color: #1d4ed8;
  background: #eef4ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.04);
}

.nav-item.active::before {
  background: #2563eb;
}

.nav-item:hover {
  border-color: #d4dde8;
  color: #1d4ed8;
  background: #f3f7ff;
}

.sidebar-note {
  margin-top: 18px;
  padding: 10px;
  background: #f8fafc;
}

.main {
  padding: 20px;
}

.topbar {
  margin: -20px -20px 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 0 rgba(204, 215, 229, 0.7);
}

.topbar h2 {
  margin-top: 4px;
  font-size: 23px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0;
}

.user-badge {
  min-height: 34px;
  background: #f8fafc;
}

.ghost-button,
.primary-button {
  min-height: 36px;
}

.view.active {
  gap: 14px;
}

.filters,
.order-status-tabs {
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  height: 30px;
  border-color: #d5deea;
  background: #fff;
  color: #526070;
}

.chip.active {
  color: #1d4ed8;
  background: #eef4ff;
  border-color: #bfd0ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.04);
}

.kpi-grid,
.content-grid,
.record-grid,
.monitor-summary {
  gap: 10px;
}

.kpi,
.panel,
.record,
.monitor-stat,
.stack-item,
.audit-row {
  border-color: #d5deea;
  box-shadow: 0 1px 2px rgba(24, 39, 75, 0.04);
}

.kpi {
  position: relative;
  min-height: 98px;
  padding: 14px 14px 14px 16px;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #0f9f8e;
}

.kpi:nth-child(2)::before,
.kpi:nth-child(6)::before {
  background: #2563eb;
}

.kpi:nth-child(3)::before,
.kpi:nth-child(7)::before {
  background: #c47f16;
}

.kpi:nth-child(4)::before,
.kpi:nth-child(8)::before {
  background: #4f63d7;
}

.kpi strong {
  margin-top: 8px;
  font-size: 26px;
}

.panel {
  padding: 14px;
}

.panel-head {
  min-height: 34px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf1f6;
}

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

.panel-head span {
  font-size: 12px;
}

.toolbar {
  gap: 10px;
  margin-bottom: 10px;
  padding: 9px;
  background: #f8fafc;
}

.form-grid {
  gap: 12px;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.toolbar input,
.toolbar select {
  min-height: 38px;
  border-color: #cfd9e6;
  background: #fff;
}

.record {
  padding: 12px;
  background: #fff;
}

.record:hover {
  border-color: #bfd0ff;
  background: #fbfdff;
}

.record-title {
  min-width: 0;
}

.record-title span:first-child {
  overflow-wrap: anywhere;
}

.record-meta {
  gap: 6px;
}

.table-wrap {
  border: 1px solid #d5deea;
  background: #fff;
}

table {
  min-width: 900px;
  border-spacing: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid #d5deea;
  background: #f8fafc;
  color: #667085;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid #edf1f6;
}

td {
  background: #fff;
}

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

td:first-child,
td:last-child {
  border-radius: 0;
}

tbody tr:hover td {
  background: #f8fbff;
}

.order-manager-panel {
  padding: 14px;
}

.order-monitor-table {
  min-width: 1180px;
  table-layout: fixed;
}

.order-monitor-table th:nth-child(1),
.order-monitor-table td:nth-child(1) {
  width: 28%;
}

.order-monitor-table th:nth-child(2),
.order-monitor-table td:nth-child(2),
.order-monitor-table th:nth-child(3),
.order-monitor-table td:nth-child(3) {
  width: 10%;
}

.order-monitor-table th:nth-child(4),
.order-monitor-table td:nth-child(4),
.order-monitor-table th:nth-child(5),
.order-monitor-table td:nth-child(5) {
  width: 9%;
}

.order-monitor-table th:nth-child(6),
.order-monitor-table td:nth-child(6) {
  width: 14%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.order-monitor-table th:nth-child(7),
.order-monitor-table td:nth-child(7) {
  width: 12%;
  white-space: normal;
}

.order-monitor-table th:nth-child(8),
.order-monitor-table td:nth-child(8) {
  width: 8%;
}

.monitor-customer {
  gap: 5px;
}

.monitor-customer-title strong {
  font-size: 14px;
}

.monitor-address.is-variant {
  padding: 6px 8px;
  background: #fff8e8;
}

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

.production-order-table th {
  white-space: normal;
}

.production-row.is-warn td,
.order-row.has-address-variance td {
  background: #fffaf0;
}

.production-row.needs-revision td:first-child,
.order-row.has-address-variance td:first-child {
  box-shadow: inset 4px 0 0 #f59e0b;
}

.order-row.needs-cost td,
.order-row.has-address-variance.needs-cost td {
  background: #fff5f5;
}

.order-row.needs-cost td:first-child,
.order-row.has-address-variance.needs-cost td:first-child {
  box-shadow: inset 4px 0 0 #dc2626;
}

.rightbar h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

.alert {
  background: #fff;
}

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  body:not([data-view="dashboard"]) .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .rightbar {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .alert-list {
    grid-template-columns: repeat(3, 1fr);
  }

  #orderForm.form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  body:not([data-view="dashboard"]) .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .rightbar,
  .topbar {
    position: static;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(10, minmax(112px, 1fr));
    overflow-x: auto;
  }

  .sidebar-note {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    margin: -18px -18px 16px;
    padding: 16px 18px;
  }

  .kpi-grid,
  .content-grid,
  .form-grid,
  #batches.active,
  #customers.active,
  #inventory.active,
  #after-sales.active,
  #access.active,
  #orderForm.form-grid,
  .monitor-summary,
  .alert-list {
    grid-template-columns: 1fr;
  }

  #batches > .panel:nth-child(3),
  #customers > .panel:nth-child(3),
  #inventory > .panel:nth-child(3),
  #inventory > .panel:nth-child(4),
  #access > .panel:nth-child(3),
  #access > .panel:nth-child(4) {
    grid-column: auto;
  }

  .span-2 {
    grid-column: span 1;
  }

  .size-field {
    grid-template-columns: 1fr;
  }

  .tracking-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main,
  .rightbar,
  .sidebar {
    padding: 14px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions .danger {
    grid-column: span 2;
  }

  .record-grid {
    grid-template-columns: 1fr;
  }

  #orderList .record,
  #customerList .record,
  #batchList .record,
  #afterSaleList .record,
  #accountList .record {
    grid-template-columns: 1fr;
  }

  #orderList .order-thumb,
  #orderList .record-title,
  #orderList .record-meta,
  #orderList .pill,
  #orderList .record-actions,
  #customerList .record-title,
  #customerList .record-meta,
  #customerList .record-actions,
  #batchList .record-title,
  #batchList .record-meta,
  #batchList .record-actions,
  #afterSaleList .record-title,
  #afterSaleList .record-meta,
  #afterSaleList .record-actions,
  #accountList .record-title,
  #accountList .record-meta,
  #accountList .record-actions {
    grid-column: auto;
    grid-row: auto;
  }

  #orderList .order-thumb {
    width: 100%;
    height: 140px;
  }

  .image-paste-field {
    align-items: stretch;
    flex-direction: column;
  }

  .paste-actions {
    justify-content: stretch;
  }

  .paste-actions .mini-button {
    flex: 1;
  }
}
