:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel2: #243044;
  --text: #e8eef5;
  --muted: #9aa8b8;
  --brand: #2d8cff;
  --accent: #22c55e;
  --danger: #ef4444;
  --border: #334155;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 1.25rem; }
nav.tabs { display: flex; gap: 8px; }
nav.tabs button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
nav.tabs button.active {
  background: var(--brand);
  border-color: var(--brand);
}
main { padding: 16px 20px; max-width: 1400px; margin: 0 auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar input, .toolbar select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}
button.btn {
  background: var(--brand);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
button.btn.secondary { background: var(--panel2); border: 1px solid var(--border); }
button.btn.success { background: var(--accent); }
button.btn.danger { background: #7f1d1d; color: #fecaca; }
button.btn.danger:hover { filter: brightness(1.08); }
button.btn.danger:disabled { opacity: 0.45; cursor: not-allowed; }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
table.orders {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.orders th, table.orders td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
table.orders th { color: var(--muted); font-weight: 600; }
table.orders tr:hover { background: var(--panel2); }
.print-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
  font-size: 13px;
}
.print-status.printed { border-color: var(--accent); color: #b8f0c8; }
.print-status.printing,
.print-status.queued { border-color: var(--brand); color: #b8d4ff; }
.print-status.print_failed,
.print-status.partial_print { border-color: var(--danger); color: #fecaca; }
.badge.print-none { opacity: 0.5; }
.badge.print-queued,
.badge.print-printing { background: #1e3a5f; color: #93c5fd; }
.badge.print-printed { background: #14532d; color: #86efac; }
.badge.print-partial_print,
.badge.print-print_failed { background: #7f1d1d; color: #fecaca; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--panel2);
}
.badge.shipped { background: #14532d; }
.badge.error { background: #7f1d1d; }
.badge.cancelled { background: #374151; color: #d1d5db; }
.badge.amazon-confirmed { background: #14532d; color: #86efac; font-size: 11px; margin-top: 4px; display: inline-block; }
.badge.amazon-failed { background: #78350f; color: #fde68a; font-size: 11px; margin-top: 4px; display: inline-block; }
.badge.amazon-skipped { background: #1f2937; color: #9ca3af; font-size: 11px; margin-top: 4px; display: inline-block; }
.order-error {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.35;
  color: #fecaca;
  max-width: 320px;
  word-break: break-word;
}
.order-error-summary {
  font-weight: 600;
  margin-bottom: 4px;
}
.order-error-meta {
  color: #fca5a5;
  font-size: 10px;
  margin-bottom: 4px;
}
.order-error-lines {
  margin: 4px 0 0;
  padding-left: 16px;
  color: #fecaca;
}
.order-error-lines li {
  margin-bottom: 3px;
}
.order-error-hint {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(127, 29, 29, 0.35);
  border-radius: 6px;
  color: #fde68a;
  font-size: 10px;
  line-height: 1.4;
}
.order-error-hint code {
  font-size: 10px;
  color: #fef3c7;
}
.order-error-inline {
  font-size: 11px;
  line-height: 1.35;
  color: #fecaca;
  display: block;
  max-width: 220px;
  word-break: break-word;
}
tr.batch-order-row { cursor: pointer; }
tr.batch-order-row:hover { background: var(--panel2); }
.batch-order-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.batch-order-link:hover { text-decoration: underline; }
tr.order-row-focus {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: #1e3a5f !important;
}
.badge.batched { background: #1e3a5f; }
.hidden { display: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.shipping-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}
.shipping-cell select { width: 100%; font-size: 12px; }
.shipping-cell .rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rate-display {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  min-width: 4em;
}
.rate-display.loading { color: var(--muted); font-weight: 500; font-size: 12px; }
.rate-display.error { color: var(--danger); font-size: 12px; font-weight: 600; }
.shipping-cell .btn-quote { padding: 4px 8px; font-size: 11px; }

.print-options .form-row { margin-bottom: 0; }
.print-options { gap: 12px; align-items: end; }
.form-row { margin-bottom: 12px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 400px;
  display: none;
  z-index: 99;
}
#toast.show { display: block; }

.products-col { min-width: 220px; max-width: 320px; }
.product-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.product-line:last-child { margin-bottom: 0; }
.product-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel2);
  border: 1px solid var(--border);
}
.product-thumb.placeholder {
  display: inline-block;
}
.product-title {
  font-size: 12px;
  line-height: 1.3;
  max-width: 240px;
}
.package-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 140px;
}
.package-cell input {
  width: 48px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
}
.package-cell .pkg-x { color: var(--muted); font-size: 11px; }
.package-cell .btn-save-pkg { padding: 4px 8px; font-size: 11px; }
.muted { color: var(--muted); }
.products-table code { font-size: 11px; }
.orders-print-toolbar {
  gap: 8px;
  padding-top: 0;
}
.orders-print-toolbar .btn:disabled {
  opacity: 0.45;
}
.ship-to-cell .btn-edit-address {
  margin-top: 6px;
  padding: 4px 8px;
  font-size: 11px;
}
#orderAddressPanel code {
  font-size: 12px;
  color: var(--muted);
}
