:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --text: #1c2430;
  --muted: #607080;
  --border: #d9e0e6;
  --primary: #16615a;
  --primary-dark: #104c47;
  --accent: #b85c24;
  --danger: #a63d40;
  --success-bg: #e7f4ed;
  --success-text: #17623e;
  --error-bg: #fae8e8;
  --error-text: #8f2428;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #17212b;
  color: #ffffff;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 28px;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 190px;
}

.brand a {
  font-size: 18px;
  font-weight: 700;
}

.brand span {
  color: #b9c5cf;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav a {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #edf3f7;
  font-size: 14px;
  padding: 8px 10px;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-group {
  position: relative;
}

.nav-group summary {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #edf3f7;
  cursor: pointer;
  font-size: 14px;
  list-style: none;
  padding: 8px 10px;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group[open] summary,
.nav-group summary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-menu {
  background: #17212b;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  min-width: 160px;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 5;
}

.nav-menu a {
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: block;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px;
}

.page-heading {
  margin-bottom: 22px;
}

.page-heading h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 0 0 6px;
}

.page-heading p {
  color: var(--muted);
  margin: 0;
  max-width: 760px;
}

.notice {
  border-radius: 6px;
  font-weight: 650;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.notice.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.notice.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.stat-grid,
.content-grid,
.action-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

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

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

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

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

.stat-card {
  min-height: 130px;
  padding: 18px;
}

.stat-card.accent {
  border-top: 4px solid var(--accent);
}

.stat-label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin: 14px 0 8px;
}

.stat-card small {
  color: var(--muted);
}

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

.panel h2 {
  font-size: 18px;
  margin: 0 0 14px;
}

.section-note {
  color: var(--muted);
  margin: 0 0 14px;
  max-width: 780px;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 42px;
}

.choice-item {
  align-items: center;
  background: #ffffff;
  border: 1px solid #c9d3dc;
  border-radius: 6px;
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
}

.choice-item input {
  margin: 0;
  min-height: auto;
  width: auto;
}

.choice-item span {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.empty-inline {
  align-items: center;
  color: var(--muted);
  display: flex;
  min-height: 42px;
}

.multi-select {
  min-height: 140px;
  padding: 6px 8px;
}

.panel-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0;
}

.link-button,
.button-link {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--primary);
  display: inline-flex;
  font-size: 14px;
  font-weight: 700;
  padding: 7px 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 720px;
  table-layout: auto;
  width: 100%;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

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

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

.pill {
  background: var(--surface-soft);
  border-radius: 999px;
  color: #26534e;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 8px;
  white-space: nowrap;
}

.pill.inactive,
.pill.cancelled {
  background: #f0e6e6;
  color: var(--danger);
}

.pill.shipped {
  background: #e8edf3;
  color: #34475a;
}

.pill.paid,
.pill.active {
  background: #e4f3eb;
  color: #17623e;
}

.pill.warning,
.pill.unmatched,
.pill.mismatch,
.pill.missing-internal,
.pill.missing-external {
  background: #fff0e3;
  color: #9a4e12;
}

.pill.error {
  background: #f0e6e6;
  color: var(--danger);
}

.pill.matched,
.pill.success {
  background: #e4f3eb;
  color: #17623e;
}

.line-item {
  display: block;
  white-space: nowrap;
}

.form-grid,
.stack-form {
  display: grid;
  gap: 14px;
}

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

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

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

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #c9d3dc;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  align-self: end;
  display: flex;
  gap: 8px;
}

button {
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  min-height: 42px;
  padding: 9px 13px;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--primary-dark);
}

button.secondary {
  background: #ffffff;
  color: var(--primary);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.row-actions form {
  margin: 0;
}

.pre-wrap {
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .nav-menu {
    position: static;
  }

  .stat-grid,
  .content-grid,
  .action-grid,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .page {
    padding: 20px 14px;
  }

  .topbar {
    padding: 12px 14px;
  }

  .page-heading h1 {
    font-size: 26px;
  }
}
