:root {
  color-scheme: light;
  --bg: #f7ecd0;
  --panel: #fff8df;
  --ink: #2d2518;
  --muted: #766b58;
  --line: #d8c18a;
  --gold: #d8a21d;
  --gold-dark: #8f6112;
  --order-link: #a06f1f;
  --green: #6b7f32;
  --red: #9d3f35;
  --red-dark: #6f2a24;
  --shadow: 0 18px 48px rgba(63, 45, 18, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(216, 162, 29, 0.22), transparent 34%),
    repeating-linear-gradient(90deg, rgba(45, 37, 24, 0.035) 0 1px, transparent 1px 18px),
    var(--bg);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 24px;
  border-bottom: 2px solid rgba(45, 37, 24, 0.12);
}

.brand-lockup {
  display: flex;
  align-items: stretch;
  gap: 14px;
  min-width: 0;
}

.client-logo {
  width: clamp(59.535px, 7.7175vw, 94.815px);
  height: clamp(59.535px, 7.7175vw, 94.815px);
  align-self: stretch;
  flex: 0 0 auto;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}

.nav-link {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(143, 97, 18, 0.28);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--gold-dark);
  background: rgba(255, 248, 223, 0.72);
  font: 800 0.78rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: #342b1c;
  color: #f3d677;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-dark);
  font: 700 0.8rem/1.1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 223, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.toolbar-selection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
}

.select-all input,
.order-check {
  width: 20px;
  height: 20px;
  accent-color: var(--gold-dark);
}

.ship-date-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.ship-date-filter input {
  width: 118px;
  min-height: 36px;
  border: 1px solid rgba(143, 97, 18, 0.24);
  border-radius: 9px;
  background: rgba(255, 248, 223, 0.72);
  color: var(--ink);
  padding: 0 10px;
  font: 800 0.82rem/1 "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.02em;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ship-date-filter input:focus {
  outline: none;
  border-color: rgba(196, 138, 20, 0.7);
  background: rgba(255, 250, 232, 0.98);
  box-shadow: 0 0 0 3px rgba(216, 162, 29, 0.16);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.service-restart-btn {
  position: fixed;
  top: 12px;
  right: 16px;
  width: 39.5px;
  height: 39.5px;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: transparent;
  box-shadow: none;
  color: rgba(118, 107, 88, 0.72);
  opacity: 0.48;
}

.service-restart-btn .fa.fa-refresh::before {
  content: "↻";
  font-size: 19.8px;
  line-height: 1;
  font-style: normal;
}

.service-restart-btn .fa.fa-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 39.5px;
  height: 39.5px;
  font-weight: 700;
}

.service-restart-btn:hover,
.service-restart-btn:focus-visible {
  opacity: 0.9;
  color: var(--ink);
}

.service-restart-btn.is-restarting {
  opacity: 0.9;
}

.activity {
  margin: -8px 0 18px;
  padding: 10px 12px;
  border: 1px solid rgba(143, 97, 18, 0.28);
  border-radius: 7px;
  background: rgba(255, 248, 223, 0.74);
  color: var(--gold-dark);
  font-weight: 800;
}

.activity.with-progress {
  display: grid;
  grid-template-columns: minmax(180px, max-content) auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
}

.activity.error {
  border-color: rgba(157, 63, 53, 0.34);
  color: var(--red);
}

.inline-progress-percent {
  color: var(--muted);
  font: 800 0.74rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button.primary {
  background: var(--gold);
  color: #221706;
  box-shadow: 0 10px 22px rgba(143, 97, 18, 0.22);
}

.button.danger {
  background: var(--red);
  color: #fff8df;
  box-shadow: 0 10px 22px rgba(157, 63, 53, 0.22);
}

.button.primary.danger {
  border-color: rgba(111, 42, 36, 0.34);
  background: linear-gradient(180deg, #b44b3f, var(--red-dark));
  color: #fff8df;
  box-shadow: 0 10px 22px rgba(111, 42, 36, 0.28);
}

.button.primary.danger:hover {
  background: linear-gradient(180deg, #c35346, #792d26);
}

.button.primary.danger:disabled {
  background: linear-gradient(180deg, #b44b3f, var(--red-dark));
  color: #fff8df;
}

.button.danger .message-icon::after {
  background: transparent;
}

.button.secondary {
  border-color: var(--line);
  background: #3d3321;
  color: #fff8df;
}

.orders-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: rgba(255, 248, 223, 0.46);
}

.table-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 0;
  padding: 4px 4px 0;
  border: 1px solid rgba(216, 193, 138, 0.8);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 248, 223, 0.72);
}

.table-tab {
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px 6px 0 0;
  padding: 0 14px;
  color: var(--gold-dark);
  background: transparent;
  cursor: pointer;
  font: 800 0.78rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-tab.active {
  background: #342b1c;
  color: #f3d677;
}

.orders-count {
  margin-left: auto;
  padding: 0 14px;
  color: var(--gold-dark);
  font: 800 0.78rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.orders-header,
.order-row {
  display: grid;
  grid-template-columns: 180px minmax(340px, 1.25fr) 96px 104px minmax(240px, 0.82fr);
  gap: 16px;
  align-items: center;
}

.orders-header {
  z-index: 3;
  margin-top: 0;
  padding: 12px 18px;
  border-radius: 8px 8px 0 0;
  color: var(--gold-dark);
  background: #342b1c;
  font: 800 0.76rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  isolation: isolate;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
}

.sort-header:hover,
.sort-header:focus-visible {
  color: #d8a21d;
}

.sort-indicator {
  width: 0.7em;
  color: #d8a21d;
}

.orders-list {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-bottom: 1px solid rgba(216, 193, 138, 0.72);
}

.order-row {
  min-height: 118px;
  padding: 16px 18px;
  border-top: 1px solid rgba(216, 193, 138, 0.72);
  background: rgba(255, 248, 223, 0.58);
}

.order-row:nth-child(even) {
  background: rgba(238, 217, 157, 0.24);
}

.order-row-problematic,
.order-row-problematic:nth-child(even) {
  background: linear-gradient(90deg, rgba(157, 63, 53, 0.16), rgba(255, 248, 223, 0.64));
}

.order-id {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  font: 800 0.9rem/1.25 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.order-check-placeholder {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
}

.cancel-warning {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(151, 78, 56, 0.48);
  border-radius: 999px;
  background: rgba(151, 78, 56, 0.13);
  color: #974e38;
  font: 900 0.85rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  cursor: help;
}

.order-id-link,
.order-id-link:link,
.order-id-link:visited {
  color: var(--order-link) !important;
  text-decoration-color: rgba(160, 111, 31, 0.42);
  text-underline-offset: 3px;
}

.order-id-link:hover,
.order-id-link:focus-visible {
  color: var(--gold-dark) !important;
  text-decoration-color: currentColor;
}

.product {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.product-items {
  display: grid;
  gap: 10px;
}

.product-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.product-item img {
  display: block;
  width: auto;
  height: auto;
  max-width: 74px;
  max-height: 92px;
  flex: 0 0 auto;
  border-radius: 4px;
}

.placeholder-img {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 6px;
  background: #d8c18a;
}

.placeholder-img {
  display: grid;
  place-items: center;
  border: 1px solid rgba(45, 37, 24, 0.18);
  color: var(--gold-dark);
  font-weight: 900;
}

.product-title {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.18;
}

.order-meta {
  display: grid;
  gap: 2px;
  padding-left: 88px;
}

.buyer,
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.details {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.item-details-list {
  display: grid;
  gap: 8px;
}

.item-details {
  display: grid;
  gap: 3px;
}

.item-details + .item-details {
  padding-top: 8px;
  border-top: 1px solid rgba(89, 70, 36, 0.16);
}

.date-cell {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.25;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 56px 20px;
  color: var(--muted);
  text-align: center;
}

.chatbot-shell {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.chatbot-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin: 22px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 223, 0.86);
  box-shadow: var(--shadow);
}

.message-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
}

.message-icon {
  width: 22px;
  height: 15.4px;
  display: inline-block;
  border: 2px solid currentColor;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.message-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  top: -6px;
  width: 13.2px;
  height: 13.2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  background: transparent;
}

.respond-progress {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.progress-line,
.progress-stats {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--gold-dark);
  font: 800 0.78rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress-stats {
  color: var(--muted);
  font-weight: 700;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(143, 97, 18, 0.28);
  border-radius: 999px;
  background: rgba(216, 193, 138, 0.38);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8f6112, #d8a21d);
  transition: width 220ms ease;
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid rgba(216, 193, 138, 0.8);
  border-radius: 8px;
  background: rgba(255, 248, 223, 0.5);
  box-shadow: 0 12px 32px rgba(63, 45, 18, 0.12);
  overflow: hidden;
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
}

.chat-messages.dragging {
  outline: 2px dashed var(--gold-dark);
  outline-offset: -10px;
  background: rgba(216, 162, 29, 0.09);
}

.chat-message {
  display: flex;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.bot,
.chat-message.system {
  justify-content: flex-start;
}

.message-bubble {
  width: min(760px, 88%);
  padding: 13px 15px;
  border: 1px solid rgba(216, 193, 138, 0.72);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 248, 223, 0.9);
  line-height: 1.35;
  box-shadow: 0 8px 18px rgba(63, 45, 18, 0.08);
}

.chat-message.user .message-bubble {
  border-color: rgba(143, 97, 18, 0.34);
  background: #3d3321;
  color: #fff8df;
}

.chat-message.success .message-bubble,
.chat-message.system.success .message-bubble {
  border-color: rgba(107, 127, 50, 0.42);
  background: rgba(233, 236, 194, 0.86);
}

.chat-message.error .message-bubble,
.chat-message.system.error .message-bubble {
  border-color: rgba(157, 63, 53, 0.38);
  background: rgba(246, 222, 208, 0.86);
  color: var(--red);
}

.message-bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.message-bubble small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font: 700 0.76rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  text-transform: uppercase;
}

.sent-attachments,
.processed-attachments,
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sent-attachments,
.processed-attachments {
  margin-top: 10px;
}

.sent-attachments span,
.processed-attachments span,
.attachment-chip {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(216, 193, 138, 0.62);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--gold-dark);
  background: rgba(255, 248, 223, 0.76);
  font: 700 0.76rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.processed-attachments .bad {
  color: var(--red);
  border-color: rgba(157, 63, 53, 0.32);
  background: rgba(246, 222, 208, 0.68);
}

.chat-composer {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(216, 193, 138, 0.8);
  background: rgba(255, 248, 223, 0.92);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #fff8df;
  background: #342b1c;
  cursor: pointer;
  font: 900 1.4rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.composer-main {
  min-height: 42px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(216, 193, 138, 0.86);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 252, 238, 0.86);
}

.attachment-chip {
  border: 1px solid rgba(143, 97, 18, 0.24);
  cursor: pointer;
}

.attachment-chip strong {
  color: var(--red);
}

#chat-input {
  width: 100%;
  min-height: 24px;
  max-height: 180px;
  border: 0;
  padding: 0;
  resize: none;
  outline: none;
  color: var(--ink);
  background: transparent;
  line-height: 1.35;
  font: inherit;
}

#chat-input::placeholder {
  color: rgba(118, 107, 88, 0.78);
}

.send-button {
  min-width: 96px;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    gap: 14px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .client-logo {
    width: 52px;
    height: 52px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-selection {
    align-items: stretch;
    flex-direction: column;
  }

  .ship-date-filter {
    justify-content: space-between;
  }

  .ship-date-filter input {
    width: 140px;
  }

  .toolbar-actions {
    flex-direction: column;
  }

  .orders-header {
    display: none;
  }

  .order-row {
    grid-template-columns: 1fr;
  }

  .order-meta {
    padding-left: 0;
  }

  .chatbot-actions {
    grid-template-columns: 1fr;
  }

  .chat-composer {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .send-button {
    grid-column: 1 / -1;
  }

  .message-bubble {
    width: 94%;
  }
}
