* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  color: #1a1a17;
  background: #f6f5f0;
  font-size: 14px;
  line-height: 1.5;
}
main { max-width: 1300px; margin: 24px auto; padding: 0 24px 80px; }
h1 { font-weight: 500; letter-spacing: -0.02em; margin-bottom: 6px; }
h2 { font-weight: 500; letter-spacing: -0.01em; }
h3 { font-weight: 500; margin-bottom: 12px; }

.muted { color: #8a8a82; font-size: 12px; }
code {
  background: #efece4;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
}
pre {
  background: #efece4;
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  overflow-x: auto;
  max-height: 280px;
  font-family: ui-monospace, monospace;
}
.hide { display: none; }

/* Top nav */
.topnav {
  background: white;
  border-bottom: 1px solid #e0ddd2;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topnav strong { letter-spacing: -0.01em; }
.topnav a {
  color: #5a5a55;
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 5px;
}
.topnav a:hover { background: #efece4; color: #1a1a17; }
.topnav a.active { background: #1a1a17; color: white; }
.topnav-spacer { flex: 1; }

/* Cards */
.card {
  background: white;
  border: 1px solid #e0ddd2;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* Buttons */
button {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid #d0ccc0;
  background: white;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
button:hover { background: #f6f5f0; border-color: #8a8a82; }
button.primary { background: #ff5c1f; color: white; border-color: #ff5c1f; }
button.primary:hover { background: #e54e15; border-color: #e54e15; }
button.danger { color: #c1342e; border-color: #f0b8b6; }
button.danger:hover { background: #fbe9e8; border-color: #c1342e; }
button.dark { background: #1a1a17; color: white; border-color: #1a1a17; }
button.dark:hover { background: #2a2a26; border-color: #2a2a26; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.sm { font-size: 11px; padding: 5px 10px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  background: #efece4;
  padding: 8px 10px;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a5a55;
}
tbody td { padding: 9px 10px; border-top: 1px solid #e0ddd2; vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #faf8f1; }
tr.selected { background: #fff1ea; }

/* Pills */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-new { background: #fdf3df; color: #b87514; }
.pill-acknowledged { background: #e3f1ea; color: #1f7a4a; }
.pill-draft { background: #e7eefc; color: #1d4ed8; }
.pill-ready { background: #e3f1ea; color: #1f7a4a; }
.pill-mono { background: #e7eefc; color: #1d4ed8; }
.pill-mix { background: #fdf3df; color: #b87514; }

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.alert-error { background: #fbe9e8; color: #c1342e; }
.alert-error ul { margin: 6px 0 0 18px; padding: 0; }
.alert-success { background: #e3f1ea; color: #1f7a4a; }
.alert-warning { background: #fdf3df; color: #b87514; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(20,20,17,0.5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal-bg.open { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  max-width: 950px;
  width: 100%;
  padding: 24px 28px;
}
.modal h2 { margin: 0 0 6px; }
.modal-meta { color: #8a8a82; font-size: 13px; margin-bottom: 20px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e0ddd2;
}

/* Form inputs */
input, select, textarea {
  padding: 6px 10px;
  border: 1px solid #d0ccc0;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  background: white;
}
input:focus, select:focus, textarea:focus { border-color: #5a5a55; }
input.over-limit {
  border-color: #c1342e;
  background: #fbe9e8;
  color: #c1342e;
}
.field-group { margin-bottom: 12px; }
.field-group label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a5a55;
  margin-bottom: 4px;
}

/* Ack-modal table */
.ack-table input, .ack-table select {
  padding: 4px 8px;
  font-size: 12px;
}
.ack-table input[type=number] { width: 70px; text-align: right; }
.ack-table input[type=date] { width: 130px; }
.quick-buttons { display: flex; gap: 6px; margin-bottom: 12px; }

/* Shipment workbench */
.workbench {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}
.workbench-col { display: flex; flex-direction: column; gap: 12px; }
.col-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5a5a55;
  font-weight: 500;
  margin-bottom: 6px;
}

/* Carton card */
.carton {
  background: white;
  border: 1px solid #e0ddd2;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}
.carton-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #efece4;
  border-bottom: 1px solid #e0ddd2;
}
.carton-num {
  width: 28px; height: 28px;
  background: #1a1a17;
  color: white;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 14px;
  margin-right: 10px;
}
.carton-contents { padding: 0; }
.carton-content-row {
  display: grid;
  grid-template-columns: 1fr auto 70px 24px;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid #efece4;
  align-items: center;
  font-size: 12px;
}
.carton-content-row:last-child { border-bottom: none; }
.carton-add-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 8px;
  padding: 8px 14px;
  background: #faf8f1;
  border-bottom: 1px solid #e0ddd2;
  align-items: center;
}
.carton-foot {
  display: grid;
  grid-template-columns: 90px 90px 1fr auto;
  gap: 10px;
  padding: 10px 14px;
  align-items: end;
}

.x-btn {
  width: 22px;
  height: 22px;
  background: transparent;
  border: 1px solid #e0ddd2;
  border-radius: 4px;
  cursor: pointer;
  color: #8a8a82;
  font-size: 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.x-btn:hover { background: #fbe9e8; color: #c1342e; border-color: #f0b8b6; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: white;
  border: 1px solid #e0ddd2;
  border-radius: 8px;
  padding: 12px 14px;
}
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a8a82;
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.stat-value .unit { font-size: 12px; color: #8a8a82; margin-left: 3px; }
.stat-value.warn { color: #c1342e; }
.stat-value.ok { color: #1f7a4a; }

/* PO source list */
.po-source-card {
  background: white;
  border: 1px solid #e0ddd2;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.po-source-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}
.po-source-item {
  display: grid;
  grid-template-columns: 1fr 70px 60px;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  align-items: center;
  border-top: 1px solid #efece4;
}
.po-source-item:first-of-type { border-top: 1px solid #e0ddd2; margin-top: 4px; padding-top: 8px; }
.po-source-name { font-weight: 500; }
.po-source-meta { font-size: 10px; color: #8a8a82; font-family: ui-monospace, monospace; }
