:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --surface: #f8fafc;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --line-soft: #edf0f4;
  --accent: #1666a7;
  --accent-strong: #0f4f82;
  --accent-soft: #e8f2fc;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --tooltip: #111827;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

h2,
h3,
h4,
p {
  margin-top: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.topbar-right,
.nav,
.panel-header,
.stack-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-right {
  justify-content: flex-end;
}

.nav a,
.nav-link {
  padding: 7px 4px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.nav a:hover,
.nav-link:hover {
  color: var(--accent);
}

.page-shell {
  width: min(1500px, calc(100vw - 40px));
  margin: 20px auto 56px;
}

.panel,
.mini-card {
  overflow: visible;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.mini-card {
  padding: 16px;
}

.panel h2,
.panel h3,
.mini-card h3 {
  margin-bottom: 12px;
}

.narrow-panel {
  max-width: 720px;
}

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

.stack {
  display: grid;
  gap: 12px;
}

.stack-right {
  justify-content: flex-end;
}

.top-gap {
  margin-top: 18px;
}

.eyebrow,
.muted,
small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.panel-header {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-label-row,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.field-label {
  min-width: 0;
  color: #202b37;
  font-size: 13px;
  font-weight: 750;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 420px) max-content;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 650;
}

.checkbox input {
  width: auto;
  min-height: auto;
}

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  max-width: 100%;
  padding: 8px 13px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-strong);
}

.button-secondary {
  background: #fff;
  color: var(--accent);
}

.button-secondary:hover {
  background: var(--accent-soft);
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
}

.button-danger:hover {
  background: #8f1d15;
}

.button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.info-button {
  position: relative;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  border: 1px solid #b7c4d6;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 17px;
  text-align: center;
  cursor: help;
}

.info-button:hover,
.info-button.is-open {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tooltip-host[data-tooltip]::after,
.tooltip-host[data-tooltip]::before {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.14s ease,
    transform 0.14s ease,
    visibility 0.14s ease;
  z-index: 1000;
}

.tooltip-host[data-tooltip]::after {
  content: attr(data-tooltip);
  left: 50%;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: min(340px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--tooltip);
  color: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.22);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
  white-space: pre-line;
  transform: translate(-50%, 4px);
}

.tooltip-host[data-tooltip]::before {
  content: "";
  left: 50%;
  bottom: calc(100% + 4px);
  border: 6px solid transparent;
  border-top-color: var(--tooltip);
  transform: translate(-50%, 4px);
}

.button.tooltip-host:hover::after,
.button.tooltip-host:hover::before,
.button.tooltip-host:focus-visible::after,
.button.tooltip-host:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0.65s;
}

.info-button.tooltip-host::after {
  top: calc(100% + 9px);
  bottom: auto;
}

.info-button.tooltip-host::before {
  top: calc(100% + 3px);
  bottom: auto;
  border-top-color: transparent;
  border-bottom-color: var(--tooltip);
}

.info-button.tooltip-host.is-open::after,
.info-button.tooltip-host.is-open::before,
.info-button.tooltip-host:focus-visible::after,
.info-button.tooltip-host:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0s;
}

.topbar .button.tooltip-host::after {
  top: calc(100% + 10px);
  bottom: auto;
}

.topbar .button.tooltip-host::before {
  top: calc(100% + 4px);
  bottom: auto;
  border-top-color: transparent;
  border-bottom-color: var(--tooltip);
}

.compact-header {
  margin-bottom: 8px;
}

.pipeline-panel {
  overflow: visible;
}

.pipeline-panel-inline {
  min-width: 0;
  margin: 6px 0 18px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.pipeline-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: visible;
  padding: 6px 0 2px;
}

.pipeline-track {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  padding: 0;
  margin: 0;
  list-style: none;
}

.pipeline-step {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 0 4px;
  color: var(--muted);
  text-align: center;
}

.pipeline-connector {
  position: absolute;
  top: 18px;
  left: -50%;
  right: 50%;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  z-index: 0;
}

.pipeline-step:first-child .pipeline-connector {
  display: none;
}

.pipeline-step-complete .pipeline-connector,
.pipeline-step-action .pipeline-connector,
.pipeline-step-skipped .pipeline-connector,
.pipeline-step-cancelled .pipeline-connector {
  background: var(--accent);
}

.pipeline-marker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 3px solid #98a2b3;
  border-radius: 50%;
  background: #fff;
  color: #98a2b3;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.pipeline-step strong {
  color: inherit;
  font-size: 14px;
  line-height: 1.2;
}

.pipeline-step span:last-child {
  font-size: 13px;
  line-height: 1.2;
}

.pipeline-step-complete {
  color: var(--ink);
}

.pipeline-step-complete .pipeline-marker {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.pipeline-step-action {
  color: #7a4b00;
}

.pipeline-step-action .pipeline-marker {
  border-color: #f79009;
  background: #fffbeb;
  box-shadow: 0 0 0 5px #fef0c7;
}

.pipeline-step-skipped .pipeline-marker {
  border-style: dashed;
  background: var(--surface);
}

.pipeline-step-cancelled {
  color: var(--danger);
}

.pipeline-step-cancelled .pipeline-marker {
  border-color: var(--danger);
  background: #fff5f5;
  color: var(--danger);
}

.pipeline-step.tooltip-host:hover::after,
.pipeline-step.tooltip-host:hover::before,
.pipeline-step.tooltip-host:focus-visible::after,
.pipeline-step.tooltip-host:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0.25s;
}

.pipeline-step.tooltip-host::after {
  bottom: calc(100% + 12px);
}

.pipeline-step.tooltip-host::before {
  bottom: calc(100% + 6px);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.orders-table {
  min-width: 1260px;
}

.receiving-table {
  min-width: 900px;
}

.integration-table {
  min-width: 980px;
}

.data-table th,
.data-table td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table th {
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.data-table tbody tr:hover td {
  background: #fbfdff;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table a {
  white-space: nowrap;
}

.orders-table th:nth-child(1),
.orders-table td:nth-child(1) {
  width: 104px;
  overflow-wrap: normal;
}

.orders-table th:nth-child(2),
.orders-table td:nth-child(2) {
  width: 86px;
  overflow-wrap: normal;
}

.orders-table th:nth-child(3),
.orders-table td:nth-child(3) {
  width: 120px;
}

.orders-table th:nth-child(4),
.orders-table td:nth-child(4) {
  width: 230px;
}

.orders-table th:nth-child(5),
.orders-table td:nth-child(5) {
  width: 120px;
}

.orders-table th:nth-child(6),
.orders-table td:nth-child(6) {
  width: 210px;
}

.orders-table th:nth-child(7),
.orders-table td:nth-child(7) {
  width: 160px;
}

.orders-table th:nth-child(9),
.orders-table td:nth-child(9) {
  width: 90px;
}

.orders-table td:nth-child(1),
.orders-table td:nth-child(2),
.orders-table td:nth-child(5),
.orders-table td:nth-child(6),
.receiving-table td:nth-child(4),
.receiving-table td:nth-child(5) {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.filter-link,
.badge,
.session-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.filter-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.filter-link:hover,
.filter-link.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-neutral {
  background: #eef2f7;
  color: #344054;
}

.badge-danger {
  background: #fee4e2;
  color: var(--danger);
}

.badge-warning {
  background: #fef0c7;
  color: var(--warning);
}

.badge-success {
  background: #dcfae6;
  color: var(--success);
}

.session-pill {
  background: #eef2f7;
  white-space: nowrap;
}

.definition-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.definition-list li {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 12px;
}

.definition-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-text {
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}

.media-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
}

.media-thumb,
.evidence-thumb-link {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.media-thumb {
  width: 92px;
  height: 92px;
}

.evidence-thumb-link {
  width: 58px;
  height: 58px;
}

.media-thumb img,
.evidence-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.evidence-item {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  margin-bottom: 8px;
}

.evidence-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.evidence-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  object-fit: contain;
}

.timeline {
  padding-left: 20px;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #9fc5e8;
  border-radius: 8px;
  background: #eff8ff;
  color: #184e77;
}

.balance {
  margin-bottom: 8px;
  font-size: 28px;
  font-weight: 850;
}

.code-block {
  overflow-x: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
}

@media (max-width: 980px) {
  .topbar,
  .panel-header,
  .topbar-right {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-right,
  .nav,
  .stack-right {
    justify-content: flex-start;
  }

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

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

@media (max-width: 640px) {
  .topbar {
    padding: 14px 16px;
  }

  .page-shell {
    width: calc(100vw - 16px);
    margin-top: 12px;
  }

  .panel,
  .mini-card {
    padding: 14px;
  }

  .definition-list li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .pipeline-track {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    row-gap: 18px;
  }

  .pipeline-step:nth-child(5n + 1) .pipeline-connector {
    display: none;
  }

  .pipeline-marker {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .pipeline-connector {
    top: 16px;
  }
}
