:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --ink: #20272a;
  --muted: #667174;
  --line: #d9dfdc;
  --panel: #ffffff;
  --accent: #0b6f66;
  --accent-strong: #074f49;
  --soft: #e7f2ef;
  --green: #26734d;
  --amber: #a45f16;
  --red: #a33a33;
  --blue: #2b628f;
  --focus: #efbd42;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button,
.button {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 9px;
  text-decoration: none;
  white-space: nowrap;
}

button.primary,
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

button.subtle {
  background: #f8faf9;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

input,
select,
textarea {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 5px 8px;
}

.checkbox-select {
  position: relative;
  min-width: 0;
}

.checkbox-select-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: flex-start;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  text-align: left;
  text-overflow: ellipsis;
  padding-right: 24px;
}

.checkbox-select-button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-top: 5px solid var(--muted);
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

.checkbox-select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 3px);
  left: 0;
  display: none;
  width: min(340px, max(100%, 260px));
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 14px 26px rgba(22, 34, 37, 0.16);
  padding: 4px;
}

.checkbox-select.open .checkbox-select-menu {
  display: grid;
  gap: 1px;
}

.checkbox-select-option {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  border-radius: 4px;
  padding: 5px 6px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1.22;
  cursor: pointer;
}

.checkbox-select-option:hover {
  background: #f0f5f3;
}

.checkbox-select-option input {
  width: 13px;
  min-height: 13px;
  margin: 1px 0 0;
  padding: 0;
}

textarea {
  min-height: 46px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 42%, transparent);
  outline-offset: 1px;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-gate[hidden],
.orders-shell[hidden] {
  display: none;
}

.auth-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
}

.auth-panel h1,
.topbar h1 {
  margin: 0;
  letter-spacing: 0;
}

.auth-panel p {
  color: var(--muted);
}

.orders-shell {
  width: min(1500px, calc(100% - 18px));
  margin: 0 auto;
  padding: 14px 0 22px;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: 1.55rem;
  line-height: 1.08;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.user-chip {
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0 9px;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(116px, 1fr));
  align-items: end;
  gap: 7px;
  margin-bottom: 8px;
}

.control-bar label,
.result-form label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.invoice-search-field {
  display: grid;
  gap: 3px;
}

.invoice-lookup-loader {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 850;
}

.invoice-lookup-loader[hidden] {
  display: none;
}

.mini-spinner {
  width: 11px;
  height: 11px;
  border: 2px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: invoice-spinner 700ms linear infinite;
}

@keyframes invoice-spinner {
  to {
    transform: rotate(360deg);
  }
}

.filter-notice {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 850;
}

.filter-notice[hidden] {
  display: none;
}

.filter-actions {
  display: flex;
  grid-column: 6 / -1;
  justify-content: flex-end;
  gap: 7px;
}

.filter-actions button {
  min-width: 118px;
}

.load-progress {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.load-progress[hidden] {
  display: none;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.progress-head strong {
  color: var(--accent-strong);
  font-size: 0.78rem;
}

.progress-track {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe8;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 8px 0;
}

.summary-grid article,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-grid article {
  min-height: 56px;
  padding: 9px 10px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
  line-height: 1;
}

.summary-action {
  display: inline-block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.summary-action strong {
  border-radius: 6px;
  padding: 3px 6px;
  margin-left: -6px;
}

.summary-action:hover strong,
.summary-action:focus-visible strong {
  background: rgba(22, 163, 74, 0.12);
  outline: none;
}

.summary-action.active strong {
  background: #dcfce7;
  color: #166534;
}

.table-panel {
  overflow: visible;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
}

.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head h2 {
  font-size: 0.92rem;
}

.panel-head p,
#credentialNote {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
  padding: 7px 11px;
}

.pagination-bar-bottom {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0 0 8px 8px;
}

.pagination-bar button {
  min-height: 24px;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 850;
}

.pagination-bar span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.pagination-bar label {
  display: inline-grid;
  grid-template-columns: auto 68px;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
}

.pagination-bar select {
  min-height: 24px;
  padding: 2px 6px;
}

.orders-table {
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-gutter: stable;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.orders-table::-webkit-scrollbar {
  display: none;
}

.table-scroll-proxy {
  position: sticky;
  z-index: 15;
  bottom: 0;
  height: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #f8faf9;
  scrollbar-gutter: stable;
}

.table-scroll-proxy[hidden] {
  display: none;
}

.table-scroll-proxy-inner {
  height: 1px;
}

.orders-head,
.order-group {
  display: grid;
  grid-template-columns: 112px 120px minmax(170px, 0.8fr) 92px minmax(205px, 1fr) minmax(190px, 0.95fr) minmax(145px, 0.7fr) minmax(180px, 0.85fr) minmax(180px, 0.85fr) minmax(180px, 0.85fr) minmax(180px, 0.85fr) 126px minmax(330px, 1.05fr);
  min-width: 2380px;
}

.orders-head {
  border-bottom: 1px solid var(--line);
  background: #f0f4f2;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.orders-head span,
.order-cell {
  min-width: 0;
  padding: 7px 8px;
}

.orders-head b {
  color: var(--ink);
}

.order-group {
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.order-group:last-child {
  border-bottom: 0;
}

.invoice-group-cell {
  background: #fbfcfd;
}

.order-group.processing-self {
  background: #edf8f0;
}

.order-group.processing-other {
  background: #f0f2f3;
}

.order-group.processing-self .order-cell,
.order-group.processing-self .invoice-group-cell {
  background: transparent;
}

.order-group.processing-other .order-cell,
.order-group.processing-other .invoice-group-cell {
  background: transparent;
}

.inventory-subrow-cell {
  border-top: 1px dashed var(--line);
}

.invoice-id {
  display: block;
  font-weight: 900;
}

.fulfillment-status,
.invoice-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.muted {
  color: var(--muted);
  font-size: 0.72rem;
}

.customer-name,
.customer-reference {
  display: block;
}

.customer-reference,
.customer-inventory-count {
  margin-top: 3px;
}

.event-name {
  display: block;
  margin-top: 2px;
  font-weight: 800;
}

.inventory-detail-line,
.inventory-listing-id,
.inventory-load-message,
.inventory-event-id,
.vendor-name {
  display: block;
}

.inventory-detail-line {
  color: var(--ink);
}

.inventory-listing-id,
.inventory-load-message,
.inventory-event-id {
  margin-top: 3px;
}

.vendor-name {
  font-weight: 850;
}

.inventory-detail-list {
  display: grid;
  gap: 1px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.pill {
  display: inline-grid;
  min-height: 19px;
  align-items: center;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.68rem;
  font-weight: 900;
}

.pill.complete,
.pill.ok {
  background: #e3f2e9;
  color: var(--green);
}

.invoice-status .pill,
.pill.contact-needed {
  border: 1px solid #b9dfc8;
  background: #e3f2e9;
  color: var(--green);
}

.pill.pending,
.pill.review {
  background: #fff1dc;
  color: var(--amber);
}

.pill.failed {
  background: #fae6e3;
  color: var(--red);
}

.pill.upload-proof {
  background: #e8eef9;
  color: var(--blue);
}

.pill.to-process {
  background: #eef1f0;
  color: var(--accent-strong);
}

.pill.processing {
  background: #e5eff7;
  color: var(--blue);
}

.pill.none {
  background: #eef1f0;
  color: var(--muted);
}

.inventory-id-list {
  display: grid;
  gap: 5px;
}

.inventory-listing {
  display: grid;
  justify-items: start;
  gap: 2px;
}

.inventory-id-chip {
  display: inline-grid;
  min-height: 19px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfb;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 850;
  padding: 1px 7px;
  overflow-wrap: anywhere;
}

.note-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.note-table-row {
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.72rem;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-table-row:last-child {
  border-bottom: 0;
}

.note-footer {
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 800;
}

.note-footer-label {
  color: var(--muted);
}

.note-footer-value {
  color: var(--text);
}

.note-empty-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.note-refresh-button {
  min-height: 22px;
  padding: 0 7px;
  font-size: 0.68rem;
  font-weight: 850;
}

.processing-button {
  min-height: 22px;
  padding: 0 7px;
  font-size: 0.68rem;
  font-weight: 850;
}

.processing-box,
.result-form {
  display: grid;
  gap: 5px;
}

.processing-note {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result-form {
  grid-template-columns: 104px minmax(220px, 2fr) auto;
  grid-template-areas:
    "status comment save"
    "assignee comment save";
  align-items: end;
}

.result-status-field {
  grid-area: status;
}

.result-assignee-field {
  grid-area: assignee;
}

.result-comment-field {
  grid-area: comment;
}

.result-comment {
  margin-top: 5px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result-form button[type="submit"] {
  grid-area: save;
}

.result-form textarea {
  min-height: 76px;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state {
  min-width: 1050px;
  padding: 20px 12px;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 900px) {
  .orders-shell {
    width: min(100% - 20px, 1500px);
  }

  .topbar,
  .panel-head {
    align-items: start;
    flex-direction: column;
  }

  .control-bar,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
