:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #071d19;
  --muted: #62736f;
  --line: #d7e0dc;
  --primary: #0f6d5b;
  --primary-strong: #084f43;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c2410c;
  --green: #15803d;
  --sidebar: #10231d;
  --shadow: 0 18px 45px rgba(24, 45, 38, .10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

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

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--sidebar);
}

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

.login-card h1,
.brand-row h1,
.topbar h2 {
  margin: 0;
}

.login-card p,
.brand-row p,
.eyebrow,
.sub,
#modalSubtitle {
  margin: 0;
  color: var(--muted);
}

.login-card label,
.field {
  display: grid;
  gap: 6px;
}

.login-card input,
.field input,
.field select,
.field textarea,
.search {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  outline: 0;
}

.field textarea {
  min-height: 70px;
  padding: 8px 10px;
  resize: vertical;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: 18px 14px;
  background: var(--sidebar);
  color: #eef8f3;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #ffd166;
  color: #102016;
  font-weight: 800;
}

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

.nav button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #e8f2ee;
  text-align: left;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .10);
}

.workspace {
  min-width: 0;
  padding: 18px;
}

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

.eyebrow {
  color: var(--primary);
  font-weight: 800;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search {
  width: min(420px, 44vw);
}

.btn,
.icon-btn,
.text-btn {
  border: 0;
  cursor: pointer;
}

.btn {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 700;
}

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

.btn.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.btn.ghost {
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.text-btn {
  background: transparent;
  color: var(--primary);
  font-weight: 800;
}

.text-btn.danger {
  color: var(--red);
}

.action-strip {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfa;
}

.strip-note {
  margin-right: auto;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

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

.shipment-workbench {
  min-height: 360px;
}

.shipment-workbench.simple {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 0;
}

.status-tabs {
  width: 226px;
  height: 50px;
  min-height: 50px;
  max-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  align-self: start;
  gap: 6px;
  margin: 10px 12px 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-tab {
  width: 104px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.status-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(18, 126, 96, .18);
}

.status-tab strong {
  min-width: 18px;
  font-size: inherit;
  line-height: 1;
  text-align: left;
}

.pending-filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) 120px 140px 140px auto;
  gap: 8px;
  align-items: end;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfa;
}

.pending-filter-bar label {
  display: grid;
  gap: 4px;
}

.pending-filter-bar span {
  color: var(--muted);
  font-size: 11px;
}

.pending-filter-bar input,
.pending-filter-bar select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: #fff;
}

.pending-filter-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.document-filter-bar {
  grid-template-columns: repeat(4, minmax(130px, 1fr)) 120px 120px 136px 136px auto;
}

.document-summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.document-summary > div:first-child {
  margin-right: auto;
}

.document-summary strong,
.document-summary b {
  display: block;
  color: var(--text);
}

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

.document-summary b {
  font-size: 18px;
}

.shipment-toolbar {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}

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

.shipment-toolbar span {
  color: var(--muted);
}

.ship-qty {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: #fff;
}

.pending-table-wrap {
  max-height: calc(100vh - 310px);
}

.pending-table {
  min-width: 1080px;
}

.pending-table th:first-child,
.pending-table td:first-child {
  width: 54px;
  text-align: center;
}

.pending-table .ship-qty {
  width: 92px;
}

.mini-pill {
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef5f1;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-pill.green {
  background: #e7f6ee;
  color: var(--green);
}

.mini-pill.red {
  background: #fff0e8;
  color: var(--red);
}

.disabled-line {
  background: #fbfbfa;
  color: var(--muted);
}

.selected-row {
  background: #f1faf6;
}

.row-check {
  width: 15px;
  height: 15px;
}

.ship-qty {
  width: 78px;
}

.empty.compact {
  padding: 12px 10px;
}

.text-btn:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f1f6f4;
  color: #40566f;
  font-weight: 800;
  white-space: nowrap;
}

td strong {
  display: block;
}

td .text-btn + .text-btn {
  margin-left: 8px;
}

.status-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eaf5f1;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.red {
  background: #fff0e8;
  color: var(--red);
}

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

.badge.blue {
  background: #edf4ff;
  color: var(--blue);
}

.badge.green {
  background: #e7f6ee;
  color: var(--green);
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(4, 15, 12, .52);
}

.modal-panel {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eef4f1;
  color: var(--text);
  font-size: 20px;
}

.icon-btn.tiny {
  width: 24px;
  height: 24px;
  font-size: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field.full {
  grid-column: 1 / -1;
}

.shipment-document-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.shipment-document-info > div {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fbfa;
}

.shipment-document-info span {
  color: var(--muted);
}

.shipment-document-info strong {
  font-size: 15px;
}

.shipment-summary {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fbfa;
}

.shipment-order-summary {
  overflow: hidden;
  border: 1px solid #e3ece8;
  border-radius: 8px;
  background: #fff;
}

.shipment-order-summary + .shipment-order-summary {
  margin-top: 8px;
}

.shipment-order-summary header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: #f3f8f6;
  border-bottom: 1px solid #e3ece8;
}

.shipment-order-summary header strong,
.shipment-order-summary header span {
  display: block;
}

.shipment-order-summary header span,
.shipment-order-summary p em {
  color: var(--muted);
  font-style: normal;
}

.shipment-order-summary header b {
  display: block;
  text-align: right;
  color: var(--primary);
}

.shipment-order-summary p {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .55fr) 56px;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid #e8efeb;
}

.shipment-order-summary p:last-child {
  border-bottom: 0;
}

.shipment-order-summary p span,
.shipment-order-summary p em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shipment-order-summary p b {
  text-align: right;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.check-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

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

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 12px;
  border-radius: 8px;
  background: #10231d;
  color: #fff;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav button {
    text-align: center;
    padding: 0 8px;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .top-actions {
    display: grid;
    width: 100%;
  }

  .search {
    width: 100%;
  }

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

  .shipment-toolbar {
    align-items: flex-start;
    display: grid;
  }

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

@media (max-width: 560px) {
  .metric-grid,
  .nav {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 20px;
  }
}
