:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --ink: #182230;
  --muted: #667085;
  --line: #d8dde6;
  --panel: #ffffff;
  --blue: #1f6feb;
  --blue-dark: #185abc;
  --green: #13795b;
  --amber: #a15c07;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 10px 18px;
  background: #172033;
  color: #fff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.topbar p {
  margin-top: 2px;
  color: #c7d2e4;
}

main {
  padding: 6px 8px 8px;
}

button,
select,
input,
a,
textarea {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

button,
a {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
a:hover {
  border-color: #9aa7b8;
}

.danger {
  color: var(--red);
  border-color: #f3b3ad;
  background: #fff7f6;
}

.danger:hover {
  border-color: var(--red);
}

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

.primary:hover {
  background: var(--blue-dark);
}

.commit {
  background: #13795b;
  color: #fff;
  border-color: #13795b;
  font-weight: 700;
}

.commit:hover {
  background: #0f684e;
  border-color: #0f684e;
}

.actions,
.filters,
.bulkbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.worktop {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.2fr);
  gap: 8px;
  align-items: stretch;
}

.panel,
.worktop form,
.stats {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.panel {
  margin-top: 6px;
}

.filters {
  background: #eef7ff;
  border-color: #b8d9ff;
}

.stats {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
}

.stat {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
}

.stat-filter {
  cursor: pointer;
}

.stat-filter:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 10px rgba(31, 111, 235, 0.12);
}

.stat strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
  white-space: nowrap;
}

.stat span {
  margin-top: 4px;
  white-space: nowrap;
}

.stat span,
.row label,
small {
  color: var(--muted);
}

form {
  display: grid;
  gap: 6px;
  align-content: start;
}

.row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  align-items: center;
}

#searchInput {
  width: min(320px, 100%);
}

#dateFilter,
#shipDateFilter {
  width: 170px;
}

.filter-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding-left: 10px;
  border: 1px solid #c6dbef;
  border-radius: 6px;
  background: #fff;
  color: #31506d;
}

.filter-field span {
  white-space: nowrap;
  font-size: 13px;
}

.filter-field input {
  border: 0;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.bulkbar {
  margin-bottom: 6px;
}

#message {
  color: var(--green);
  font-weight: 600;
}

.table-wrap {
  overflow: auto;
  height: calc(100vh - 205px);
  max-height: none;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 1660px;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 4px 7px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #eef2f7;
  z-index: 1;
  text-align: left;
  white-space: nowrap;
}

th:nth-child(1),
td:nth-child(1) {
  width: 50px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 110px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 116px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 205px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 280px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 58px;
  text-align: center;
}

th:nth-child(7),
td:nth-child(7) {
  width: 130px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 132px;
}

th:nth-child(9),
td:nth-child(9) {
  width: 160px;
}

th:nth-child(10),
td:nth-child(10) {
  width: 150px;
}

th:nth-child(11),
td:nth-child(11) {
  width: 155px;
}

th:nth-child(12),
td:nth-child(12) {
  width: 234px;
}

th:nth-child(13),
td:nth-child(13) {
  width: 80px;
}

td input,
td select,
td textarea {
  width: 100%;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  background: transparent;
}

td input:focus,
td select:focus,
td textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
}

textarea {
  resize: vertical;
}

.order-no {
  font-family: Consolas, monospace;
  white-space: normal;
  word-break: break-all;
}

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 12px;
  margin-top: 2px;
  color: #fff;
}

.tag.multi {
  background: var(--amber);
}

.tag.customer {
  background: var(--blue);
}

.tag.abnormal,
.stat.abnormal {
  background: #fff1f0;
  border-color: #f3b3ad;
  color: var(--red);
}

.tag.abnormal {
  background: var(--red);
  color: #fff;
}

tr.dirty {
  background: #fff8df;
}

tr.dirty td:first-child {
  border-left: 4px solid #d99a00;
}

tr.dirty input,
tr.dirty select,
tr.dirty textarea {
  background: #fffdf4;
}

@media (max-width: 900px) {
  .topbar,
  .worktop {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  main {
    padding: 10px;
  }
}
