/*
 * ORDERS STRUCTURE AUDIT (Appily + legacy)
 * — HTML tables with sortable columns (generic / ledger shops).
 * — Vertical stack of identical order cards (card grid / harbor rows).
 * — Month timeline spine with expanding knots (prior A122 od-spine / dew-month-spine).
 * — Chrono Pulse nodes · Strikebook racks · Haul Tag boards · Firing Log plates.
 * — Binding index shelves · Plot Ledger field-guide mosaic · Greenhouse clipboard hang.
 * — Shuffle Court zones · Invoice Fan blades · Dendro rings · Semaphore masts.
 *
 * THIS PAGE: STATUS COLUMN BOARD — summary stats mast, filter chips, then kanban lanes
 * (Processing · In transit · Delivered · Cancelled) of compact expandable slips. Mobile: swipeable tabs per lane.
 */

.page-orders,
.page-a122-orders {
  overflow-x: visible;
  background: linear-gradient(
    180deg,
    var(--sg-paper) 0%,
    color-mix(in srgb, var(--sg-mist) 22%, var(--sg-bone)) 50%,
    var(--sg-bone) 100%
  );
}

.page-a122-orders #ordersLoggedIn[hidden],
.page-a122-orders #ordersLoggedOut[hidden],
.page-a122-orders #ordersEmpty[hidden],
.page-a122-orders #ordersLoading[hidden] {
  display: none !important;
}

.or-archive {
  padding: var(--sg-space-5) 0 var(--sg-space-10);
  min-width: 0;
}

.or-archive__inner {
  min-width: 0;
  max-width: 72rem;
}

.or-archive__mast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sg-space-4);
  margin-bottom: var(--sg-space-5);
  align-items: flex-start;
}

.or-archive__mast .ds-title {
  font-size: var(--sg-text-2xl);
}

.or-archive__mast-copy {
  flex: 1 1 16rem;
  max-width: 48ch;
  min-width: 0;
}

.or-archive__stats {
  flex: 0 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sg-space-3);
  padding: var(--sg-space-4);
  min-width: min(100%, 18rem);
  margin: 0;
  background: var(--sg-paper);
  border: 1px solid var(--sg-line);
  box-shadow: var(--sg-shadow-sm, 0 1px 2px rgb(0 0 0 / 6%));
}

.or-archive__stats dt {
  margin: 0;
  font-size: var(--sg-text-xs);
  font-weight: 600;
  color: var(--sg-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.or-archive__stats dd {
  margin: var(--sg-space-1) 0 0;
  font-size: var(--sg-text-xl);
  font-weight: 700;
  color: var(--sg-sage-deep);
  overflow-wrap: anywhere;
}

.or-archive__stats div:last-child dd {
  font-size: var(--sg-text-base);
  color: var(--sg-charcoal);
}

.or-archive__stage {
  min-width: 0;
}

.or-archive__loading {
  padding: var(--sg-space-5);
  text-align: center;
  color: var(--sg-ink-muted);
  font-weight: 600;
  border: 1px dashed var(--sg-line);
  border-radius: var(--sg-radius-lg);
  background: var(--sg-paper);
}

.or-archive__guest {
  padding: var(--sg-space-5);
  max-width: 40rem;
}

.or-archive__guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sg-space-3);
  margin-top: var(--sg-space-4);
}

.or-archive__guest-actions .ds-btn {
  min-height: var(--sg-touch);
}

.or-archive__toolbar {
  margin-bottom: var(--sg-space-4);
}

.or-archive__filters {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--sg-space-2);
  overflow-x: auto;
  padding: var(--sg-space-3);
  -webkit-overflow-scrolling: touch;
  border-radius: var(--sg-radius-lg);
  background: var(--sg-paper);
  border: 1px solid var(--sg-line);
  box-shadow: var(--sg-shadow-sm, 0 1px 2px rgb(0 0 0 / 6%));
}

.or-archive__chip {
  flex: 0 0 auto;
  min-height: var(--sg-touch);
  padding: 0 var(--sg-space-3);
  border-radius: 999px;
  border: 1px solid var(--sg-line);
  background: var(--sg-paper);
  font-size: var(--sg-text-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.or-archive__chip.is-active {
  background: var(--sg-sage);
  color: var(--sg-paper);
  border-color: var(--sg-sage);
}

.or-archive__chip:hover,
.or-archive__chip:focus-visible {
  border-color: var(--sg-sage);
  outline: none;
}

/* Mobile column tabs */
.or-board__tabs {
  display: flex;
  gap: var(--sg-space-2);
  overflow-x: auto;
  margin-bottom: var(--sg-space-3);
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sg-space-1);
}

.or-board__tab {
  flex: 0 0 auto;
  min-height: var(--sg-touch);
  padding: 0 var(--sg-space-3);
  border-radius: var(--sg-radius);
  border: 1px solid var(--sg-line);
  background: var(--sg-paper);
  font-size: var(--sg-text-xs);
  font-weight: 600;
  cursor: pointer;
}

.or-board__tab.is-active {
  background: color-mix(in srgb, var(--sg-sage) 14%, var(--sg-paper));
  border-color: var(--sg-sage);
}

@media (min-width: 1024px) {
  .or-board__tabs {
    display: none;
  }
}

/* Kanban board */
.or-board {
  display: grid;
  gap: var(--sg-space-3);
  min-width: 0;
}

@media (min-width: 1024px) {
  .or-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
  }
}

.or-col {
  min-width: 0;
  display: none;
  flex-direction: column;
  gap: var(--sg-space-2);
  padding: var(--sg-space-3);
  border-radius: var(--sg-radius-lg);
  background: color-mix(in srgb, var(--sg-mist) 18%, var(--sg-paper));
  border: 1px solid var(--sg-line);
}

@media (min-width: 1024px) {
  .or-col {
    display: flex;
  }
}

.or-col.is-tab-active {
  display: flex;
}

.or-col__head {
  margin-bottom: var(--sg-space-2);
}

.or-col__title {
  margin: 0;
  font-family: var(--sg-font-display);
  font-size: var(--sg-text-sm);
  font-weight: 600;
}

.or-col__hint {
  margin: var(--sg-space-1) 0 0;
  font-size: var(--sg-text-xs);
  color: var(--sg-ink-muted);
}

.or-col__stack {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sg-space-2);
  min-width: 0;
}

.or-col.is-empty .or-col__placeholder {
  display: list-item;
}

.or-col__placeholder {
  padding: var(--sg-space-4);
  text-align: center;
  font-size: var(--sg-text-xs);
  color: var(--sg-ink-muted);
  border: 1px dashed var(--sg-line);
  border-radius: var(--sg-radius);
  list-style: none;
}

.or-col:not(.is-empty) .or-col__placeholder {
  display: none;
}

/* Order slip */
.or-slip__card {
  padding: 0;
  overflow: hidden;
  min-width: 0;
  background: var(--sg-paper);
  border: 1px solid var(--sg-line);
  border-radius: var(--sg-radius);
  box-shadow: var(--sg-shadow-sm, 0 1px 2px rgb(0 0 0 / 6%));
}

.or-slip__card.is-open {
  border-color: var(--sg-sage);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sg-sage) 35%, transparent);
}

.or-slip__hit {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "id total"
    "when badge";
  gap: var(--sg-space-1) var(--sg-space-2);
  align-items: center;
  padding: var(--sg-space-3);
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  min-height: var(--sg-touch);
  font: inherit;
  color: inherit;
}

.or-slip__hit:hover,
.or-slip__hit:focus-visible {
  background: color-mix(in srgb, var(--sg-sage) 8%, transparent);
  outline: none;
}

.or-slip__id {
  grid-area: id;
  font-family: var(--sg-font-mono);
  font-size: var(--sg-text-xs);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.or-slip__when {
  grid-area: when;
  font-size: var(--sg-text-xs);
  color: var(--sg-ink-muted);
}

.or-slip__badge {
  grid-area: badge;
  justify-self: end;
  font-size: 0.65rem;
}

.or-slip__total {
  grid-area: total;
  font-family: var(--sg-font-mono);
  font-weight: 700;
  font-size: var(--sg-text-sm);
  color: var(--sg-sage-deep);
  justify-self: end;
}

.or-slip__drawer {
  padding: 0 var(--sg-space-3) var(--sg-space-3);
  border-top: 1px dashed var(--sg-line);
  font-size: var(--sg-text-xs);
}

.or-slip__drawer[hidden] {
  display: none;
}

.or-slip__summary {
  margin: var(--sg-space-2) 0;
  color: var(--sg-ink-muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.or-slip__lines {
  list-style: none;
  margin: 0 0 var(--sg-space-2);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.or-slip__lines li {
  display: flex;
  justify-content: space-between;
  gap: var(--sg-space-2);
  overflow-wrap: anywhere;
}

.or-slip__lines em {
  font-style: normal;
  font-family: var(--sg-font-mono);
  color: var(--sg-ink-muted);
}

.or-slip__status,
.or-slip__pay {
  margin: 0.35rem 0;
}

.or-slip__pay-note {
  margin: 0.35rem 0;
  padding: var(--sg-space-2) var(--sg-space-3);
  border-radius: var(--sg-radius);
  border-left: 3px solid #c45c4a;
  background: color-mix(in srgb, #c45c4a 10%, var(--sg-paper));
  color: var(--sg-charcoal);
  line-height: 1.45;
}

.or-slip__status span,
.or-slip__pay span {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sg-ink-muted);
  margin-bottom: 0.15rem;
}

.or-slip__drawer .ds-btn {
  min-height: var(--sg-touch);
  width: 100%;
  justify-content: center;
  margin-top: var(--sg-space-2);
}

.tone-cancelled .or-slip__total {
  color: var(--sg-ink-muted);
  text-decoration: line-through;
}

/* Empty page */
.or-archive__empty {
  text-align: center;
  padding: var(--sg-space-8) var(--sg-space-4);
  border-radius: var(--sg-radius-lg);
  background: var(--sg-paper);
  border: 1px solid var(--sg-line);
  box-shadow: var(--sg-shadow-sm, 0 1px 2px rgb(0 0 0 / 6%));
}

.or-archive__empty-scene {
  color: var(--sg-sage);
  max-width: 18rem;
  margin: 0 auto var(--sg-space-4);
}

.or-archive__empty-svg {
  width: 100%;
  height: auto;
}

.or-archive__empty .ds-btn {
  min-height: var(--sg-touch);
  margin-top: var(--sg-space-3);
}

@media (min-width: 768px) and (max-width: 1023px) {
  .or-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .or-col {
    display: flex;
  }
  .or-board__tabs {
    display: none;
  }
}

@media (min-width: 420px) {
  .or-slip__hit {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "id badge total"
      "when when when";
    align-items: center;
  }

  .or-slip__badge {
    justify-self: center;
  }
}
