:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #dde2ea;
  --text: #1f2937;
  --muted: #667085;
  --blue: #2563eb;
  --green: #0f9f6e;
  --orange: #d97706;
  --red: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  background: #172033;
  padding: 22px 14px;
  color: white;
  overflow-y: auto;
}
.brand {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  margin: 2px 10px 22px;
  white-space: nowrap;
}
.nav {
  display: block;
  width: 100%;
  min-height: 46px;
  margin: 5px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d7deea;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}
.nav.active, .nav:hover { background: #26354f; color: white; }

main { margin-left: 250px; min-height: 100vh; min-width: 980px; }
header {
  height: 82px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
h1 { margin: 0 0 6px; font-size: 22px; }
p { margin: 0; color: var(--muted); }
.header-actions { display: flex; gap: 10px; align-items: center; }
.user-label {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.date-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.header-actions .date-text {
  width: 142px;
  padding-right: 36px;
}
.date-native {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 30px;
  min-height: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  cursor: pointer;
}
.date-sep { color: var(--muted); }

button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}
button.primary { background: var(--blue); color: white; border-color: var(--blue); }
button.danger { color: var(--red); }
button.good { color: var(--green); }
button.warn { color: var(--orange); }
.danger { color: var(--red); }
.good { color: var(--green); }
button:disabled { opacity: .5; cursor: not-allowed; }

.view { display: none; padding: 22px 24px 40px; overflow-x: auto; }
.view.active { display: block; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(620px, 1fr)); }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.metric { font-size: 28px; font-weight: 700; margin-top: 8px; }
.metric-card {
  text-align: left;
  color: inherit;
  min-height: 116px;
}
.metric-card:hover {
  border-color: var(--blue);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .12);
}
.metric-card span {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-size: 13px;
}

.form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.form-row.two { grid-template-columns: repeat(2, 1fr); }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { margin: 0; }
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-edit {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: 680px;
}
.empty-line {
  padding: 18px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.tracking-list {
  display: grid;
  gap: 12px;
}
.tracking-card {
  display: grid;
  grid-template-columns: minmax(300px, 1.25fr) minmax(260px, 1fr) 260px 230px;
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.tracking-card.urgent {
  border-color: #f5c2c2;
  background: #fffafa;
}
.tracking-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.tracking-id {
  font-size: 15px;
}
.tracking-product {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
}
.tracking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.tracking-meta span {
  background: #f6f8fb;
  border: 1px solid #e8edf4;
  border-radius: 999px;
  padding: 2px 8px;
}
.tracking-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0;
}
.tracking-progress div {
  border: 1px solid #e8edf4;
  border-radius: 6px;
  background: #fbfcff;
  padding: 7px 9px;
}
.tracking-progress span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.tracking-progress strong {
  font-size: 18px;
}
.board-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.board-toolbar select {
  width: auto;
  min-width: 150px;
}
.production-alert {
  border: 1px solid #f5c2c2;
  background: #fffafa;
  color: var(--red);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.production-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 12px;
}
.production-grid.compact {
  grid-template-columns: repeat(3, minmax(280px, 1fr));
}
.production-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.production-card.problem {
  border-color: #f5c2c2;
  background: #fffafa;
}
.production-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.production-card-head strong {
  font-size: 16px;
}
.production-product {
  font-size: 20px;
  font-weight: 700;
  margin: 10px 0;
}
.production-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.production-numbers div {
  border: 1px solid #e8edf4;
  background: #fbfcff;
  border-radius: 6px;
  padding: 8px 10px;
}
.production-numbers span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.production-numbers strong {
  font-size: 20px;
}
.progress-line {
  height: 8px;
  background: #edf1f7;
  border-radius: 99px;
  margin: 12px 0 8px;
  overflow: hidden;
}
.progress-line span {
  display: block;
  height: 100%;
  background: var(--blue);
}
.production-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.production-note {
  margin-top: 8px;
  color: var(--text);
}
.production-edit {
  display: grid;
  grid-template-columns: 110px 120px auto;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.production-line-row {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 140px 150px 44px;
  gap: 8px;
  margin-bottom: 8px;
}
.production-lines {
  margin-top: 10px;
}
.production-lines summary {
  cursor: pointer;
  color: var(--blue);
  margin-bottom: 8px;
}
.production-line-view {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px 120px 120px;
  gap: 8px;
  align-items: center;
  border: 1px solid #e8edf4;
  background: #fbfcff;
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 6px;
}
.production-line-view em {
  font-style: normal;
  color: var(--muted);
}
.production-line-view b {
  color: var(--orange);
}
.shipment-details {
  margin: 8px 0;
  font-size: 13px;
}
.shipment-details summary {
  color: var(--blue);
  cursor: pointer;
}
.shipment-list {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}
.shipment-list div {
  display: grid;
  grid-template-columns: 90px 150px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid #e8edf4;
  border-radius: 6px;
  background: #fbfcff;
}
.shipment-list span {
  color: var(--muted);
}
.shipment-list em {
  color: var(--muted);
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qty-pill {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1d4ed8;
  font-weight: 700;
}
.tracking-problem {
  border-left: 3px solid #e5e7eb;
  padding-left: 12px;
}
.tracking-problem label {
  margin: 0 0 3px;
}
.tracking-problem p {
  color: var(--text);
  line-height: 1.45;
  margin: 0 0 10px;
}
.tracking-plan {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.tracking-plan div {
  padding: 7px 9px;
  border: 1px solid #e8edf4;
  border-radius: 6px;
  background: #fbfcff;
}
.tracking-plan span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}
.tracking-plan strong {
  font-size: 13px;
}
.tracking-operate {
  display: flex;
  align-items: stretch;
}
.tracking-edit {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
}
.mini-label {
  margin: 2px 0 -4px;
  color: var(--muted);
  font-size: 12px;
}
.ship-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.tracking-list-compact .tracking-card {
  grid-template-columns: minmax(280px, 1.3fr) minmax(220px, 1fr) 230px;
}
.tracking-list-compact .tracking-operate {
  display: none;
}
.inline-actions input[type="date"] { width: 150px; }
.search-input { width: min(360px, 100%); }
.inventory-actions {
  flex: 1;
  justify-content: flex-end;
}
.inventory-actions .search-input {
  flex: 1;
  max-width: 520px;
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  font: inherit;
  background: white;
}
.date-picker-wrap .date-native {
  width: 30px !important;
  min-width: 30px !important;
  min-height: 26px !important;
  height: 26px !important;
  padding: 0 !important;
  border: 0 !important;
  color: transparent !important;
}
.date-native::-webkit-datetime-edit,
.date-native::-webkit-date-and-time-value {
  display: none;
}
.date-native::-webkit-calendar-picker-indicator {
  cursor: pointer;
}
textarea { min-height: 68px; resize: vertical; }

table { width: 100%; border-collapse: collapse; background: white; table-layout: auto; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; word-break: keep-all; overflow-wrap: normal; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.compact td, .compact th { padding: 7px 8px; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #edf2ff;
  color: #274690;
  font-size: 12px;
  margin: 0 4px 4px 0;
}
.part-list {
  display: grid;
  gap: 6px;
  min-width: 260px;
}
.part-line {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 72px;
  align-items: center;
  gap: 12px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #e7ebf2;
  border-radius: 6px;
  background: #fbfcff;
}
.part-line-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.part-line-qty {
  justify-self: end;
  min-width: 54px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1d4ed8;
  text-align: right;
  font-weight: 700;
}
.part-pill {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 72px;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 520px;
  margin: 0 0 6px;
  padding: 5px 8px;
  border: 1px solid #e7ebf2;
  border-radius: 6px;
  background: #fbfcff;
}
.part-pill strong {
  justify-self: end;
  color: #1d4ed8;
  background: #eef4ff;
  border-radius: 999px;
  padding: 2px 8px;
}
.tag.green { background: #e9f8f1; color: var(--green); }
.tag.orange { background: #fff3df; color: var(--orange); }
.tag.red { background: #feecec; color: var(--red); }
.muted { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.line-editor { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfe; }
.scan-box {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
  margin: 0 0 12px;
}
.scan-row {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 86px;
  gap: 8px;
  margin-top: 6px;
}
.line-row {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) minmax(360px, 1fr) 120px 44px;
  gap: 8px;
  margin-bottom: 8px;
}
.line-row.delivery-line-row {
  grid-template-columns: minmax(260px, 1.1fr) minmax(260px, 1fr) 100px 120px minmax(180px, .8fr) 44px;
}
.assembly-line-row {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 140px 44px;
  gap: 8px;
  margin-bottom: 8px;
}
.outbound-line-row {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 140px 44px;
  gap: 8px;
  margin-bottom: 8px;
}
.arrival-line-head,
.arrival-line-row {
  display: grid;
  grid-template-columns: minmax(320px, 1.3fr) repeat(5, minmax(90px, .45fr)) 44px;
  gap: 8px;
  align-items: center;
}
.arrival-line-head {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 6px;
  padding: 0 4px;
}
.arrival-line-row {
  margin-bottom: 8px;
}
.split-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.split-line span {
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef4ff;
  color: #1d4ed8;
  font-weight: 700;
}
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.doc-card {
  min-width: 220px;
  display: grid;
  gap: 6px;
}
.doc-id {
  font-weight: 800;
  color: #172033;
  white-space: nowrap;
}
.doc-meta {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 4px 8px;
  font-size: 14px;
}
.doc-label { color: var(--muted); }
.doc-value { color: var(--text); font-weight: 600; }
.pending-box {
  border: 2px solid #f59e0b;
  background: #fffbeb;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.pending-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-weight: 800;
  margin-bottom: 10px;
}
.pending-meta {
  color: var(--muted);
  font-size: 14px;
}
.history-fold {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.history-fold summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}
.history-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.history-item {
  display: grid;
  grid-template-columns: 190px 1fr 110px;
  gap: 12px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}
.history-item.wide {
  grid-template-columns: 220px 260px 1fr;
}
.time-list {
  display: grid;
  gap: 6px;
}
.time-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.time-row strong {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.dispute-form {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  border-radius: 8px;
}
.dispute-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px 120px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.review-box {
  border: 2px solid #f59e0b;
  background: #fffbeb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.billing-line-head,
.billing-line-row {
  display: grid;
  grid-template-columns: 118px 105px minmax(230px, 1fr) 150px 70px 76px 86px 96px minmax(150px, 1fr) 48px;
  gap: 8px;
  align-items: center;
  min-width: 1130px;
}
.billing-line-head {
  color: var(--muted);
  font-weight: 700;
  padding: 4px 0;
}
.line-editor {
  overflow-x: auto;
}
.bill-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.bill-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
}
.bill-company {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  padding: 2px 0 12px;
  color: #172033;
}
.bill-card-head,
.bill-customer,
.bill-total,
.bill-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
.bill-card-head {
  justify-content: space-between;
  margin-bottom: 10px;
  min-height: 28px;
  justify-content: flex-end;
}
.bill-card-head strong {
  font-size: 20px;
}
.bill-customer {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.bill-customer strong {
  font-size: 22px;
}
.bill-total {
  justify-content: flex-end;
  padding-top: 10px;
  font-size: 16px;
}
.bill-total strong {
  font-size: 18px;
}
.bill-edit {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.bill-footer-code {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: right;
  font-size: 14px;
}
.bill-edit select,
.bill-edit input {
  max-width: 220px;
}
#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  background: #111827;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef3ff, #f7f9fc);
}
.login-screen.active { display: flex; }
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .12);
}
.login-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}
.login-card p { margin: 0 0 22px; }
.login-card label {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-weight: 600;
}
.login-card input {
  width: 100%;
  height: 44px;
  font-size: 16px;
}
.login-card button {
  width: 100%;
  height: 44px;
  margin-top: 22px;
  font-size: 16px;
}

@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; display: flex; overflow-x: auto; gap: 6px; }
  .brand { display: none; }
  .nav { min-width: 130px; text-align: center; }
  main { margin-left: 0; }
  header { height: auto; padding: 14px; align-items: flex-start; gap: 12px; }
  .grid.two, .grid.three, .form-row, .form-row.two { grid-template-columns: 1fr; }
  .section-head { align-items: stretch; flex-direction: column; }
  .inline-actions { width: 100%; }
}
