:root {
  --paper: #fbf6ec;
  --card: #fffdf8;
  --ink: #17120e;
  --muted: #7a6f66;
  --line: #e8dfd0;
  --red: #e2432b;
  --red-dark: #c2321c;
  --green: #2f8a4f;
  --radius: 14px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

h1 .muted {
  font-size: 1rem;
  font-weight: 500;
}

h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

code {
  background: var(--line);
  padding: 1px 5px;
  border-radius: 4px;
}

.muted {
  color: var(--muted);
}

.ok {
  color: var(--green);
  font-weight: 600;
}

/* ---------------------------------------------------------------- top bar */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px 28px;
  background: var(--ink);
  color: #fff;
}

.top__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.top__brand small,
.login__brand small {
  font-weight: 500;
  opacity: 0.6;
}

.top__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgb(226 67 43 / 0.3);
}

.top__nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.top__nav a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  opacity: 0.75;
}

.top__nav a:hover,
.top__nav a[aria-current] {
  opacity: 1;
  background: rgb(255 255 255 / 0.12);
}

.top__out {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  opacity: 0.85;
}

.top .btn--ghost {
  color: #fff;
  border-color: rgb(255 255 255 / 0.3);
}

.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn--red {
  background: var(--red);
  color: #fff;
}

.btn--red:hover {
  background: var(--red-dark);
}

.btn--dark {
  background: var(--ink);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn--ghost:hover {
  border-color: var(--ink);
}

.btn--danger {
  background: transparent;
  color: var(--red-dark);
}

.btn--danger:hover {
  background: rgb(226 67 43 / 0.08);
}

.btn--sm {
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.btn--block {
  width: 100%;
}

/* ---------------------------------------------------------------- layout */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.head__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lede {
  margin: -8px 0 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.card--flush {
  padding: 0;
  overflow-x: auto;
}

.card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.card summary {
  cursor: pointer;
  font-weight: 650;
}

.card[open] summary {
  margin-bottom: 16px;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.split--order {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  margin-top: 0;
}

.stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.flash {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #e7f3ea;
  color: #1d5a33;
  font-weight: 600;
}

.flash--error {
  background: #fbe5e1;
  color: #8f2414;
}

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}

a.stat:hover {
  border-color: var(--ink);
}

.stat__k {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--muted);
}

.stat__v {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

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

.stat--red {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.stat--red .stat__k,
.stat--red .stat__s {
  color: rgb(255 255 255 / 0.85);
}

/* ---------------------------------------------------------------- tables */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.table th,
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.card:not(.card--flush) .table td {
  padding: 8px 0;
}

.card:not(.card--flush) .table td + td {
  padding-left: 12px;
}

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

.table--click tbody tr:hover {
  background: rgb(23 18 14 / 0.03);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--line);
  font-size: 0.75rem;
  font-weight: 650;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--line);
  white-space: nowrap;
}

h1 .badge {
  font-size: 0.8125rem;
}

.badge--new { background: #fff1c9; color: #7a5600; }
.badge--paid { background: #fbe0d9; color: #a52a14; }
.badge--in_production { background: #e6e1fb; color: #4b3a9a; }
.badge--shipped { background: #dcecfb; color: #1e5a8c; }
.badge--delivered { background: #e0f1e5; color: #1d5a33; }
.badge--cancelled,
.badge--refunded { background: #eee9e2; color: var(--muted); }

/* ---------------------------------------------------------------- filters */

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

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tabs a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.tabs a span {
  opacity: 0.6;
  font-weight: 500;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current] {
  background: var(--ink);
  color: #fff;
}

.search {
  min-width: 260px;
}

/* ---------------------------------------------------------------- forms */

input,
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.form {
  display: grid;
  gap: 14px;
}

.form__group {
  display: grid;
  gap: 12px;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
}

.form__group legend {
  margin-bottom: 10px;
  font-weight: 700;
}

.form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form__row--zip {
  grid-template-columns: 140px 1fr;
}

.form__foot {
  display: flex;
  justify-content: flex-end;
}

.field {
  display: grid;
  gap: 5px;
  font-size: 0.875rem;
}

.field > span {
  font-weight: 650;
}

.field small {
  font-weight: 400;
  color: var(--muted);
}

.field--error input,
.field--error select {
  border-color: var(--red);
}

.field .field__error {
  color: var(--red-dark);
}

.copy textarea {
  margin-top: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
}

.copy {
  margin-top: 20px;
}

/* ---------------------------------------------------------------- login */

.login {
  max-width: 380px;
  margin: 10vh auto 0;
  display: grid;
  gap: 16px;
  padding: 32px;
}

.login__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 800;
}

/* ---------------------------------------------------------------- order */

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

.events li {
  display: grid;
  gap: 2px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
  font-size: 0.875rem;
}

.events__msg {
  font-weight: 600;
}

.slip__address {
  font-style: normal;
  font-size: 1.125rem;
  line-height: 1.45;
}

.slip__contact {
  margin: 12px 0 16px;
  font-size: 0.875rem;
}

.slip__items {
  border-top: 1px solid var(--line);
}

.note {
  margin: 0;
  white-space: pre-wrap;
}

.print-only {
  display: none;
}

@media (max-width: 760px) {
  .top {
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 16px;
  }

  .top__nav {
    order: 3;
    flex-basis: 100%;
  }

  .main {
    padding: 24px 16px 60px;
  }

  .split--order,
  .form__row {
    grid-template-columns: 1fr;
  }

  .search {
    min-width: 0;
    width: 100%;
  }
}

@media print {
  .top,
  .flash,
  .no-print {
    display: none !important;
  }

  .print-only {
    display: block;
  }

  body,
  .card {
    background: #fff;
  }

  .main {
    padding: 0;
  }

  .split--order {
    display: block;
  }

  .slip {
    border: 0;
    padding: 0;
  }

  .slip__brand {
    margin: 0 0 32px;
    font-weight: 800;
  }

  .slip__address {
    font-size: 1.5rem;
    margin-bottom: 32px;
  }
}
