:root {
  color-scheme: light;
  --bg: #f5f8f7;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: #dfe9e7;
  --soft-line: #edf3f2;
  --text: #182422;
  --muted: #6d7977;
  --label: #53615f;
  --primary: #159285;
  --primary-strong: #0a7068;
  --primary-dark: #08615a;
  --active: #e8f6f3;
  --danger: #a45a58;
  --danger-bg: #fff7f5;
  --danger-line: #eed9d4;
  --field: #fbfdfd;
  --field-line: #dce8e5;
  --warning: #7a520f;
  --warning-bg: #fff8ea;
  --warning-line: #ead39f;
  --shadow: 0 24px 70px rgba(22, 45, 42, 0.08);
  --button-shadow: 0 14px 24px rgba(18, 160, 147, 0.22);
}

* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  min-width: 0;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 96% -8%, rgba(82, 218, 195, 0.22), transparent 34%),
    linear-gradient(180deg, #f8fbfa 0%, var(--bg) 36%, #f2f7f6 100%);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover:not(:disabled) {
  border-color: #c8dcda;
  box-shadow: 0 10px 22px rgba(22, 45, 42, 0.07);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #0b8f83, #12b9a7);
  color: #fff;
  box-shadow: var(--button-shadow);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #087b72, #0fae9d);
}

button.danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: none;
}

input,
select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--field-line);
  border-radius: 13px;
  background: var(--field);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus {
  border-color: rgba(21, 146, 133, 0.55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(21, 146, 133, 0.11);
}

input:disabled,
select:disabled {
  background: #f2f6f5;
  color: #7b8583;
  cursor: not-allowed;
}

label {
  display: grid;
  gap: 8px;
  color: var(--label);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(26, 150, 138, 0.16);
}

.brand div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brand strong {
  overflow: hidden;
  color: #142321;
  font-size: 21px;
  line-height: 1.18;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
.security-note,
.page-head p {
  color: var(--muted);
}

.brand span {
  font-size: 12px;
}

.nav {
  width: 100%;
  height: 42px;
  margin-bottom: 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  box-shadow: none;
}

.nav:hover:not(:disabled) {
  background: rgba(232, 246, 243, 0.65);
  box-shadow: none;
}

.nav.active {
  border-color: rgba(16, 115, 107, 0.08);
  background: var(--active);
  color: var(--primary-strong);
  font-weight: 800;
}

.security-note {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 24px;
  margin: 0;
  padding: 13px 14px;
  border-radius: 14px;
  background: #edf6f3;
  font-size: 12px;
  line-height: 1.6;
}

.content {
  min-width: 0;
  overflow-x: hidden;
  padding: 32px 36px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 30px;
  line-height: 1.22;
  font-weight: 820;
}

.page-head p {
  margin: 0;
  max-width: 760px;
  font-size: 15px;
  line-height: 1.75;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(280px, 1fr) 128px;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.message-toolbar {
  grid-template-columns: minmax(220px, 270px) minmax(320px, 1fr) 128px;
}

#query-order {
  width: 128px;
  padding: 0 12px;
}

.messages-layout {
  display: grid;
  grid-template-columns: minmax(260px, 30%) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.message-list-panel,
.conversation-panel {
  min-height: 560px;
}

.thread-list {
  display: grid;
  gap: 10px;
}

.thread-card {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 18px;
  background: #fff;
  box-shadow: none;
  text-align: left;
  white-space: normal;
}

.thread-card:hover:not(:disabled),
.thread-card.active {
  border-color: #bfe3de;
  background: #eef8f6;
  box-shadow: 0 12px 24px rgba(22, 45, 42, 0.07);
}

.thread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4f3;
  color: #68757a;
  font-size: 12px;
  font-weight: 800;
}

.thread-badge.needs-reply {
  border: 1px solid #ead39f;
  background: #fff4dd;
  color: #7a520f;
}

.thread-badge.replied {
  background: #e7f5ec;
  color: #24663d;
}

.thread-time {
  position: absolute;
  top: 18px;
  right: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.thread-card strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 820;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-topic {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 6px;
  color: #33413f;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.thread-meta {
  overflow: hidden;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
  gap: 14px;
}

.conversation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.conversation-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.conversation-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1.3;
  font-weight: 820;
}

.conversation-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.conversation-head p span {
  display: inline;
}

.conversation-order-meta {
  margin-left: 10px;
  color: #93a09d;
  font-size: 12px;
  font-weight: 650;
}

.conversation-order-meta span {
  display: inline;
}

.conversation-order-link {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-strong);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 2px;
  box-shadow: none;
}

.conversation-order-link:hover:not(:disabled) {
  background: transparent;
  color: var(--primary-dark);
  box-shadow: none;
  transform: none;
}

.status.needs-reply {
  border: 1px solid #ead39f;
  background: #fff4dd;
  color: #7a520f;
}

.status.replied {
  background: #e7f5ec;
  color: #24663d;
}

.status.ignored {
  background: #eef3f2;
  color: #6b7774;
}

.message-context {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(110px, auto) minmax(260px, 1fr);
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  background: #f8fbfa;
}

.message-context .context-card-head {
  position: absolute;
  top: 12px;
  right: 12px;
}

.message-context .context-card-head button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
}

.message-context div {
  min-width: 0;
}

.message-context span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.message-context strong {
  display: block;
  overflow: visible;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 760;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.message-context .context-wide {
  grid-column: 1 / -1;
}

.message-context .context-warning {
  color: var(--warning);
  font-size: 12px;
  line-height: 1.55;
}

.message-context .context-uploaded {
  color: var(--primary-strong);
}

.message-context .context-delivery strong {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.tracking-list {
  display: block !important;
  overflow: hidden !important;
  padding-right: 0;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.tracking-button {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary-strong);
  font-size: 13px;
  line-height: 1.45;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  box-shadow: none;
}

.tracking-button + .tracking-button::before {
  color: var(--muted);
  content: " / ";
  text-decoration: none;
}

.tracking-button:hover:not(:disabled) {
  background: transparent;
  color: var(--primary-dark);
  box-shadow: none;
  transform: none;
}

.product-list {
  display: grid !important;
  gap: 6px;
}

.product-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-strong);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 760;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: none;
}

.product-link.disabled {
  color: var(--text);
  text-decoration: none;
}

.product-link:hover:not(.disabled) {
  background: transparent;
  color: var(--primary-dark);
  box-shadow: none;
  transform: none;
}

.tracking-error {
  color: var(--warning);
}

.message-history {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 300px;
  max-height: 430px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fbfdfd, #f7fbfa);
}

.message-row {
  display: flex;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(76%, 620px);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.message-row.mine .message-bubble {
  border-color: #cfe8e4;
  background: #e8f6f3;
}

.message-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.message-body {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  white-space: normal;
}

.message-body p {
  margin: 0 0 10px;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body a {
  color: var(--primary-strong);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-body ul,
.message-body ol {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.message-attachment-row,
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.message-attachment,
.selected-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4f3;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
}

.message-attachment {
  min-height: 30px;
  border: 1px solid #cfe8e4;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
}

.message-attachment:hover:not(:disabled) {
  background: #e8f6f3;
  box-shadow: none;
  transform: none;
}

.selected-file button {
  min-height: 22px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  box-shadow: none;
}

.reply-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.reply-box textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: var(--field);
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
}

.reply-box textarea:focus {
  border-color: rgba(21, 146, 133, 0.55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(21, 146, 133, 0.11);
}

.reply-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.reply-actions select {
  width: 118px;
  height: 42px;
}

.invoice-marker {
  justify-self: center;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 999px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

.invoice-marker strong {
  margin-right: 8px;
}

.invoice-marker.success {
  border: 1px solid #cfe8e4;
  background: #e8f6f3;
  color: var(--primary-strong);
}

.invoice-marker.failed {
  border: 1px solid var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(14, 25, 23, 0.28);
  backdrop-filter: blur(6px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(520px, calc(100vw - 48px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(14, 25, 23, 0.22);
}

.app-dialog-modal {
  overflow: hidden;
  width: min(560px, calc(100vw - 48px));
  padding: 0;
  border-radius: 26px;
}

.app-dialog-top {
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #ecf8f4, #ffffff);
}

.dialog-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 850;
}

.dialog-chip.success {
  background: #e8f6f3;
  color: var(--primary-strong);
}

.dialog-chip.warning {
  background: #fff8e9;
  color: #8a5a0a;
}

.dialog-chip.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.app-dialog-top h2 {
  margin: 12px 0 6px;
  font-size: 22px;
  line-height: 1.25;
}

.app-dialog-top p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.app-dialog-body {
  display: grid;
  gap: 10px;
  padding: 18px 22px 4px;
}

.app-dialog-body:empty {
  display: none;
}

.dialog-summary-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdfc;
}

.dialog-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 5px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dialog-summary-row strong {
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}

.dialog-risk-box {
  padding: 11px 12px;
  border-radius: 15px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.65;
}

.dialog-info-box {
  padding: 11px 12px;
  border-radius: 15px;
  background: #f2f8f6;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.app-dialog-actions {
  padding: 18px 22px 22px;
}

.app-dialog-actions .hidden {
  display: none;
}

.refund-modal {
  width: min(980px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  overflow: auto;
}

.modal-title-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.modal-title-row p {
  margin-top: 6px;
  font-family: inherit;
}

.refund-order-info {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 12px;
}

.refund-order-info div,
.refund-line {
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  background: #f8fbfa;
}

.refund-order-info div {
  padding: 12px;
}

.refund-order-info span,
.refund-line span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.refund-order-info strong,
.refund-line strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.refund-lines {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.refund-line {
  display: grid;
  grid-template-columns: 76px minmax(220px, 1fr) 70px 110px 110px minmax(180px, 220px);
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.refund-check {
  display: flex;
  grid-template-columns: none;
  gap: 6px;
  align-items: center;
}

.refund-check input {
  width: 16px;
  height: 16px;
}

.refund-product strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.refund-reason-wrap {
  min-width: 0;
}

.refund-summary-row {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.refund-summary-row strong {
  color: var(--text);
}

.modal h2 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.35;
}

.modal p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.message-status-stack {
  display: grid;
  justify-items: end;
  gap: 4px;
}

#message-refresh-time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.3;
  font-weight: 780;
}

.status,
#query-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f0f6f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-grid.empty {
  display: block;
  padding: 16px 0 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.summary-item {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 15px;
  background: #f8fbfa;
}

.summary-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.summary-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 730;
}

.summary-item:nth-child(3) {
  grid-column: span 2;
}

.risk-box {
  grid-column: 1 / -1;
  padding: 13px 14px;
  border: 1px solid var(--warning-line);
  border-radius: 15px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 13px;
  line-height: 1.6;
}

.risk-box strong {
  display: inline-block;
  margin-bottom: 4px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 18px;
}

.actions button {
  min-width: 116px;
}

#generate-pdf {
  min-width: 150px;
}

pre {
  min-height: 88px;
  margin: 0;
  padding: 2px 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: #33413f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

.settings-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.store-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.store-card {
  padding: 13px 14px;
  border: 1px solid var(--soft-line);
  border-radius: 15px;
  background: #f8fbfa;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.store-card:hover {
  border-color: #cfe0dd;
  box-shadow: 0 10px 20px rgba(22, 45, 42, 0.06);
  transform: translateY(-1px);
}

.store-card.active {
  border-color: rgba(21, 146, 133, 0.35);
  background: #eef8f6;
}

.store-card strong {
  display: block;
  margin-bottom: 6px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-card span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-list {
  display: grid;
  gap: 10px;
}

.record-search {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  background: #f8fbfa;
}

.memo-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.memo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 18px;
  background: rgba(248, 252, 251, 0.9);
}

.memo-toolbar button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 760;
}

.memo-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}

.memo-tool-group {
  position: relative;
  display: inline-flex;
}

.memo-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: 360px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 44px rgba(28, 45, 42, 0.16);
}

.memo-color-panel {
  display: grid;
  grid-template-columns: repeat(10, 26px);
  gap: 7px;
}

.memo-color-panel.hidden,
.memo-table-panel.hidden {
  display: none;
}

.memo-color-swatch {
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid rgba(28, 45, 42, 0.16);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.memo-color-swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(28, 45, 42, 0.12);
}

.memo-table-panel {
  width: 250px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.memo-table-panel:not(.hidden) {
  display: grid;
}

.memo-table-custom {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--soft-line);
}

.memo-table-custom label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.memo-table-custom input {
  width: 100%;
  height: 34px;
  border-radius: 10px;
}

.memo-table-custom button {
  grid-column: 1 / -1;
}

.memo-editor {
  min-height: 520px;
  padding: 22px 24px;
  border: 1px solid var(--soft-line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
  outline: none;
  overflow-wrap: anywhere;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.memo-editor:focus {
  border-color: rgba(16, 163, 148, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 163, 148, 0.1);
}

.memo-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.memo-editor h2 {
  margin: 8px 0 10px;
  font-size: 22px;
  line-height: 1.4;
}

.memo-editor p {
  margin: 0 0 12px;
}

.memo-editor ul,
.memo-editor ol {
  margin: 8px 0 14px;
  padding-left: 24px;
}

.memo-editor blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--primary);
  border-radius: 0 12px 12px 0;
  background: rgba(16, 163, 148, 0.07);
  color: var(--muted-strong);
}

.memo-editor hr {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: var(--soft-line);
}

.memo-editor table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
  table-layout: fixed;
  overflow: hidden;
  border-radius: 12px;
}

.memo-editor td,
.memo-editor th {
  min-width: 48px;
  padding: 9px 10px;
  border: 1px solid rgba(102, 125, 121, 0.28);
  background: rgba(255, 255, 255, 0.94);
  vertical-align: top;
}

.memo-editor tr:first-child td,
.memo-editor th {
  background: rgba(16, 163, 148, 0.08);
  font-weight: 760;
}

.memo-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.memo-table-context-menu {
  position: fixed;
  z-index: 80;
  display: grid;
  gap: 6px;
  min-width: 160px;
  padding: 8px;
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 44px rgba(28, 45, 42, 0.18);
}

.memo-table-context-menu.hidden {
  display: none;
}

.memo-table-context-menu button {
  justify-content: flex-start;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--text);
}

.memo-table-context-menu button:hover {
  background: var(--active);
  color: var(--primary-strong);
}

.order-filter-panel {
  margin-bottom: 18px;
}

.order-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.order-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.orders-result-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.orders-result-tools > span:not(.status) {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.orders-result-tools button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
}

.orders-list {
  display: grid;
  gap: 10px;
}

.orders-workspace {
  display: grid;
  gap: 0;
}

.order-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 10px;
}

.order-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 12px 12px 0 0;
  background: #eef4f3;
  color: var(--muted);
  box-shadow: none;
}

.order-tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.order-tab-close {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.order-tab-panel,
.order-detail-panel {
  display: none;
}

.order-tab-panel.active,
.order-detail-panel.active {
  display: block;
}

.order-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) minmax(360px, 2fr) minmax(148px, auto);
  gap: 14px;
  align-items: stretch;
  padding: 16px;
  border: 1px solid var(--soft-line);
  border-radius: 18px;
  background: #f8fbfa;
}

.order-card > div {
  min-width: 0;
}

.order-card span {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-main strong {
  font-size: 17px;
  font-weight: 820;
}

.order-main span {
  margin-top: 6px;
  color: #33413f;
  font-size: 12px;
  font-weight: 650;
}

.order-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 10px 14px;
  align-items: center;
}

.order-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  justify-content: end;
  align-content: center;
}

.order-actions button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
  text-align: center;
}

.order-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.order-detail-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.25;
}

.order-detail-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.order-detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-card {
  padding: 13px;
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  background: #f8fbfa;
}

.detail-card span,
.order-line-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.detail-card strong,
.order-line-card strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.detail-wide {
  grid-column: 1 / -1;
}

.detail-section-title {
  margin: 20px 0 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 820;
}

.order-line-list {
  display: grid;
  gap: 10px;
}

.order-line-card {
  display: grid;
  grid-template-columns: minmax(340px, 1.8fr) repeat(6, minmax(82px, 0.7fr));
  gap: 10px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  background: #fbfdfd;
}

.order-line-product {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.order-line-image {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: #f1f6f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-line-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.order-line-title strong {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 6px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-card.missing {
  border-color: #e8c1c1;
  background: #fff8f8;
}

.record-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin-bottom: 8px;
}

.record-title strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 780;
}

.record-title span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf0f2;
  color: #4b535a;
  font-size: 12px;
  font-weight: 700;
}

.badge.uploaded {
  background: #e7f5ec;
  color: #24663d;
}

.badge.failed {
  background: #fdecec;
  color: #9b2f2f;
}

.badge.cancelled,
.badge.exists_cancelled {
  background: #fff4dd;
  color: #7a520f;
}

.record-path {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.missing-text {
  color: var(--danger) !important;
  font-weight: 800;
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form label:nth-child(4),
.form label:nth-child(6),
.form label:nth-child(9),
.form label:nth-child(10) {
  grid-column: 1 / -1;
}

.path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 14px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .security-note {
    position: static;
    margin-top: 20px;
  }

  .content {
    padding: 24px;
  }

  .toolbar,
  .message-toolbar,
  .messages-layout,
  .settings-layout,
  .record-search,
  .order-card {
    grid-template-columns: 1fr;
  }

  .order-detail-head {
    display: block;
  }

  .order-detail-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .order-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-detail-grid,
  .order-line-card {
    grid-template-columns: 1fr;
  }

  .order-line-product {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .order-line-image {
    width: 64px;
    height: 64px;
  }

  .order-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #query-order {
    width: 100%;
  }

  .summary-grid,
  .form {
    grid-template-columns: 1fr;
  }

  .summary-item:nth-child(3) {
    grid-column: auto;
  }

  .page-head {
    display: block;
  }
}

/* Purple compact workspace refresh, aligned with the current finance report UI. */
:root {
  --bg: #f4f3fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --line: #e8e6f1;
  --soft-line: #f0eef7;
  --text: #171821;
  --muted: #777584;
  --label: #5b596a;
  --primary: #4f46e5;
  --primary-strong: #312e81;
  --primary-dark: #25215f;
  --active: #efedff;
  --danger: #b45355;
  --danger-bg: #fff6f5;
  --danger-line: #f0d9d8;
  --field: #fbfbff;
  --field-line: #deddeb;
  --warning: #8a5c14;
  --warning-bg: #fff8e8;
  --warning-line: #eddcb2;
  --shadow: 0 16px 46px rgba(28, 25, 84, 0.07);
  --button-shadow: 0 12px 22px rgba(79, 70, 229, 0.18);
}

body {
  background:
    radial-gradient(circle at 4% -12%, rgba(133, 117, 255, 0.18), transparent 32%),
    radial-gradient(circle at 96% 0%, rgba(45, 212, 191, 0.12), transparent 28%),
    linear-gradient(180deg, #fbfbff 0%, #f5f4fb 44%, #f1f2f8 100%);
  font-size: 12px;
}

button {
  min-height: 32px;
  padding: 0 12px;
  border-color: var(--field-line);
  border-radius: 11px;
  font-size: 12px;
  font-weight: 760;
}

button:hover:not(:disabled) {
  border-color: #cfccdf;
  box-shadow: 0 8px 18px rgba(28, 25, 84, 0.08);
}

button.primary {
  background: linear-gradient(135deg, #3f3a9f, #5b55ee);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #36318f, #514bef);
}

button.danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

input,
select,
textarea {
  border-color: var(--field-line);
  background: var(--field);
}

input,
select {
  height: 34px;
  padding: 0 10px;
  border-radius: 11px;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(79, 70, 229, 0.48);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

input:disabled,
select:disabled {
  background: #f2f1f8;
  color: #8a8796;
}

label {
  gap: 5px;
  color: var(--label);
  font-size: 11px;
  font-weight: 760;
}

.app {
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 16px;
  border-right-color: rgba(232, 230, 241, 0.84);
  background: rgba(255, 255, 255, 0.80);
  box-shadow: 14px 0 46px rgba(28, 25, 84, 0.05);
  backdrop-filter: blur(22px);
}

.brand {
  margin-bottom: 28px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  box-shadow: 0 12px 22px rgba(79, 70, 229, 0.20);
}

.brand strong {
  color: #171821;
  font-size: 19px;
  font-weight: 880;
}

.brand span {
  font-size: 11px;
}

.nav {
  height: 36px;
  margin-bottom: 7px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 760;
}

.nav:hover:not(:disabled) {
  background: rgba(239, 237, 255, 0.64);
}

.nav.active {
  border-color: rgba(79, 70, 229, 0.12);
  background: var(--active);
  color: var(--primary-strong);
  font-weight: 850;
}

.security-note {
  padding: 10px 12px;
  border: 1px solid #eeeafa;
  border-radius: 14px;
  background: #f5f4ff;
  color: #6b6880;
  font-size: 10px;
  line-height: 1.45;
}

.content {
  padding: 24px 30px;
}

.page-head {
  gap: 18px;
  margin-bottom: 14px;
}

.page-head h1 {
  margin-bottom: 5px;
  font-size: 25px;
  line-height: 1.15;
  font-weight: 900;
}

.page-head p {
  max-width: 920px;
  font-size: 12px;
  line-height: 1.5;
}

.toolbar,
.panel,
.empty-panel,
.kpi-card,
.summary-item,
.order-card,
.order-detail-panel,
.store-card,
.record-card,
.refund-line,
.refund-order-info div,
.message-context,
.reply-box,
.message-history,
.memo-panel,
.memo-editor {
  border-color: rgba(232, 230, 241, 0.94);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.toolbar {
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 16px;
}

.message-toolbar {
  grid-template-columns: minmax(170px, 220px) minmax(260px, 1fr) minmax(130px, 160px) auto;
}

#query-order {
  width: 100px;
}

.panel,
.empty-panel {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 18px;
}

.panel-head {
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head h2,
.conversation-head h2,
.modal h2,
.modal-title-row h2 {
  font-size: 14px;
  font-weight: 850;
}

.status,
.badge,
.thread-badge,
.dialog-chip {
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.status,
.badge {
  background: #efedf7;
  color: #6b6880;
}

.status.needs-reply,
.thread-badge.needs-reply {
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning);
}

.status.replied,
.thread-badge.replied,
.badge.uploaded {
  background: #e7f5ec;
  color: #24663d;
}

.status.ignored {
  background: #f1f0f6;
  color: #706d80;
}

.messages-layout {
  grid-template-columns: minmax(250px, 302px) minmax(0, 1fr);
  gap: 12px;
}

.message-list-panel,
.conversation-panel {
  min-height: 610px;
}

.thread-list {
  gap: 8px;
}

.thread-card {
  min-height: 74px;
  padding: 10px 12px;
  border-color: var(--soft-line);
  border-radius: 15px;
}

.thread-card:hover:not(:disabled),
.thread-card.active {
  border-color: #d9d4ff;
  background: #f4f2ff;
  box-shadow: 0 10px 22px rgba(28, 25, 84, 0.06);
}

.thread-time {
  top: 12px;
  right: 12px;
  font-size: 10px;
}

.thread-card strong {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.28;
}

.thread-topic {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  -webkit-line-clamp: 1;
}

.thread-meta {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.35;
}

.conversation-panel {
  gap: 10px;
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
}

.conversation-head {
  gap: 12px;
}

.conversation-head p,
.modal-title-row p,
.app-dialog-top p {
  font-size: 12px;
  line-height: 1.45;
}

.conversation-tools {
  gap: 6px;
}

.message-context {
  grid-template-columns: minmax(170px, 1.1fr) minmax(110px, .7fr) minmax(240px, 1fr);
  gap: 8px 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: none;
}

.message-context span {
  margin-bottom: 4px;
  font-size: 11px;
}

.message-context strong,
.tracking-button,
.product-link {
  font-size: 12px;
}

.message-history {
  gap: 10px;
  min-height: 290px;
  max-height: 440px;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfbff, #f7f6fc);
  box-shadow: none;
}

.message-bubble {
  max-width: min(76%, 640px);
  padding: 11px 13px;
  border-radius: 16px;
}

.message-row.mine .message-bubble {
  border-color: #dad5ff;
  background: #f1efff;
}

.message-meta {
  margin-bottom: 6px;
  font-size: 11px;
}

.message-body {
  font-size: 13px;
  line-height: 1.58;
}

.reply-box {
  padding: 10px;
  border-radius: 16px;
}

.reply-box textarea {
  min-height: 78px;
  padding: 10px 11px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.55;
}

.reply-actions {
  gap: 8px;
}

.reply-actions select {
  width: 116px;
}

.actions {
  gap: 8px;
  margin: 12px 0;
}

.summary-grid,
.order-meta-grid,
.order-detail-grid,
.refund-order-info,
.form,
.settings-layout,
.record-search,
.order-filter-grid {
  gap: 10px;
}

.summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-item,
.detail-card,
.order-line-card,
.record-card,
.refund-line,
.refund-order-info div {
  border-color: var(--soft-line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.76);
}

.summary-item {
  padding: 12px;
  min-height: 74px;
}

.summary-item span,
.detail-card span,
.order-meta-grid span,
.order-detail-grid span,
.refund-line span,
.refund-order-info span {
  font-size: 11px;
}

.summary-item strong,
.detail-card strong,
.order-meta-grid strong,
.order-detail-grid strong,
.refund-line strong,
.refund-order-info strong {
  font-size: 13px;
}

#result-log {
  padding: 12px;
  border-color: var(--soft-line);
  border-radius: 14px;
  background: #fbfbff;
  color: #302f3b;
  font-size: 12px;
  line-height: 1.55;
}

.orders-workspace {
  gap: 10px;
}

.order-tabs,
.orders-result-tools {
  gap: 6px;
}

.order-tab {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
}

.order-tab.active {
  border-color: rgba(79, 70, 229, 0.18);
  background: var(--active);
  color: var(--primary-strong);
}

.orders-list {
  gap: 9px;
}

.order-card {
  grid-template-columns: minmax(220px, 1.35fr) minmax(420px, 2fr) 118px;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
}

.order-main strong {
  font-size: 18px;
}

.order-main span {
  font-size: 12px;
}

.order-meta-grid {
  grid-template-columns: repeat(7, minmax(78px, 1fr));
}

.order-actions {
  grid-template-columns: 1fr;
  gap: 6px;
}

.order-actions button {
  min-height: 30px;
}

.order-detail-head h2 {
  font-size: 20px;
}

.order-detail-head p {
  font-size: 12px;
}

.order-line-list {
  gap: 9px;
}

.order-line-card {
  grid-template-columns: minmax(260px, 1.7fr) repeat(4, minmax(80px, .75fr));
  padding: 10px;
}

.order-line-image,
.refund-product-placeholder,
.refund-product-image {
  width: 44px;
  height: 44px;
  border-color: var(--soft-line);
  border-radius: 10px;
}

.order-line-product {
  grid-template-columns: 44px minmax(0, 1fr);
}

.order-line-title,
.refund-product strong {
  font-size: 13px;
}

.order-line-sku,
.order-line-meta,
.refund-product span {
  font-size: 11px;
}

.record-card {
  padding: 12px;
  gap: 12px;
}

.record-title {
  gap: 8px;
}

.record-title strong {
  font-size: 15px;
}

.record-title span,
.record-path {
  font-size: 11px;
}

.settings-layout {
  grid-template-columns: 260px minmax(0, 1fr);
}

.store-card {
  padding: 12px;
  border-radius: 15px;
}

.store-card strong {
  font-size: 13px;
}

.store-card span {
  font-size: 11px;
}

.form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-row input {
  width: 14px;
  height: 14px;
}

.modal-backdrop {
  background: rgba(21, 19, 46, 0.32);
}

.modal {
  border-color: rgba(232, 230, 241, 0.94);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(28, 25, 84, 0.20);
}

.refund-modal {
  width: min(1180px, calc(100vw - 52px));
}

.refund-lines {
  gap: 9px;
}

.refund-line {
  grid-template-columns: 82px minmax(260px, 1.4fr) 70px minmax(100px, .7fr) minmax(110px, .7fr) minmax(220px, 1fr);
  padding: 11px;
}

.refund-summary-row {
  padding-top: 10px;
  font-size: 13px;
}

.memo-panel {
  gap: 12px;
  padding: 14px;
}

.memo-toolbar {
  gap: 6px;
  padding: 8px;
  border-color: var(--soft-line);
  border-radius: 15px;
  background: rgba(251, 251, 255, 0.90);
}

.memo-toolbar button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.memo-popover,
.memo-table-context-menu {
  border-color: rgba(116, 104, 164, 0.18);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(27, 20, 48, 0.14);
}

.memo-editor {
  min-height: 500px;
  padding: 18px 20px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.68;
  box-shadow: none;
}

.memo-editor:focus {
  border-color: rgba(79, 70, 229, 0.48);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.memo-editor h2 {
  font-size: 19px;
}

.memo-editor blockquote {
  border-left-color: var(--primary);
  background: rgba(79, 70, 229, 0.07);
}

.memo-footer {
  font-size: 11px;
}

.dialog-chip.success {
  background: #e7f5ec;
  color: #24663d;
}

.dialog-chip.warning {
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning);
}

.dialog-chip.danger {
  border: 1px solid var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

.dialog-summary-card,
.dialog-info-box,
.dialog-risk-box {
  border-radius: 14px;
}

@media (max-width: 1180px) {
  .content {
    padding: 22px;
  }

  .messages-layout {
    grid-template-columns: 1fr;
  }

  .order-card {
    grid-template-columns: 1fr;
  }

  .order-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Compact order list redesign: narrower identity column, complete right-side data. */
.orders-list {
  overflow-x: auto;
  padding-bottom: 4px;
}

.orders-table-head,
.order-card {
  min-width: 1420px;
  grid-template-columns:
    176px
    minmax(280px, 1.25fr)
    150px
    minmax(150px, 0.8fr)
    170px
    238px
    146px
    120px;
}

.orders-table-head {
  display: grid;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  background: #f5f3ff;
}

.orders-table-head span {
  overflow: hidden;
  color: var(--label);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-card {
  display: grid;
  align-items: center;
  gap: 12px;
  min-height: 118px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
}

.order-identity {
  display: grid;
  align-content: center;
  min-height: 76px;
  padding: 12px;
  border-radius: 15px;
  background: #fbfaff;
}

.order-identity strong {
  overflow: visible;
  font-size: 18px;
  line-height: 1.2;
  text-overflow: clip;
  white-space: nowrap;
}

.order-identity span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.order-product-cell {
  min-width: 0;
}

.order-product-cell strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.order-product-cell span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.order-meta-cell {
  min-width: 0;
}

.order-meta-cell strong,
.order-meta-cell span {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.order-meta-cell strong {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.order-meta-cell span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.3;
}

.order-amount-cell strong,
.order-state-cell strong {
  white-space: nowrap;
}

.order-date-cell strong,
.order-delivery-cell strong {
  font-size: 12px;
  white-space: nowrap;
}

.order-customer-cell strong {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.order-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.order-actions button {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 11px;
}

@media (max-width: 1180px) {
  .orders-table-head,
  .order-card {
    grid-template-columns:
      160px
      260px
      138px
      140px
      160px
      220px
      136px
      112px;
  }
}

/* Final SaaS ERP refresh: white navigation + dense business workspace. */
:root {
  --erp-bg: #f5f7fb;
  --erp-surface: #ffffff;
  --erp-surface-soft: #fafbff;
  --erp-border: #e6e9f2;
  --erp-border-strong: #d7dceb;
  --erp-text: #111827;
  --erp-muted: #667085;
  --erp-subtle: #98a2b3;
  --erp-primary: #2563eb;
  --erp-primary-strong: #1d4ed8;
  --erp-primary-soft: #eff6ff;
  --erp-purple: #5b55ee;
  --erp-purple-soft: #f1efff;
  --erp-success: #15803d;
  --erp-success-soft: #ecfdf3;
  --erp-warning: #b45309;
  --erp-warning-soft: #fffbeb;
  --erp-danger: #b42318;
  --erp-danger-soft: #fff1f3;
  --erp-shadow: 0 12px 34px rgba(16, 24, 40, 0.06);
  --erp-shadow-soft: 0 6px 18px rgba(16, 24, 40, 0.04);
}

html,
body {
  background: var(--erp-bg);
}

body {
  color: var(--erp-text);
  background:
    linear-gradient(180deg, #f7f9ff 0%, #f5f7fb 38%, #f7f8fc 100%);
  font-size: 13px;
}

.app {
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  z-index: 2;
  padding: 18px 14px;
  border-right: 1px solid var(--erp-border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 8px 0 28px rgba(16, 24, 40, 0.04);
}

.brand {
  gap: 10px;
  margin-bottom: 22px;
  padding: 4px 4px 14px;
  border-bottom: 1px solid var(--erp-border);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.14);
}

.brand strong {
  color: var(--erp-text);
  font-size: 18px;
  font-weight: 900;
}

.brand span {
  color: var(--erp-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-section {
  display: block;
  margin: 18px 8px 7px;
  color: #8a94a6;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.nav {
  position: relative;
  height: 36px;
  margin-bottom: 5px;
  padding: 0 12px 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #475467;
  font-size: 13px;
  font-weight: 760;
}

.nav::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  width: 3px;
  height: 18px;
  border-radius: 999px;
  background: transparent;
}

.nav:hover:not(:disabled) {
  background: #f8faff;
  color: var(--erp-primary);
  box-shadow: none;
  transform: none;
}

.nav.active {
  border-color: #dbe7ff;
  background: var(--erp-primary-soft);
  color: var(--erp-primary-strong);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.03);
}

.nav.active::before {
  background: var(--erp-primary);
}

.security-note {
  left: 14px;
  right: 14px;
  bottom: 16px;
  padding: 10px 11px;
  border: 1px solid #e3e8f5;
  border-radius: 12px;
  background: #f8faff;
  color: #667085;
  font-size: 11px;
  line-height: 1.45;
}

.content {
  padding: 18px 24px 28px;
}

.workspace-topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -18px -24px 20px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--erp-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.workspace-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  color: #667085;
  font-size: 13px;
  font-weight: 780;
  white-space: nowrap;
}

.workspace-tab.active {
  background: var(--erp-primary-soft);
  color: var(--erp-primary-strong);
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-hint {
  padding: 7px 10px;
  border-radius: 999px;
  background: #f8faff;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--erp-primary), var(--erp-purple));
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.page-head {
  align-items: end;
  margin-bottom: 14px;
}

.page-head h1 {
  color: var(--erp-text);
  font-size: 26px;
  line-height: 1.15;
  font-weight: 920;
}

.page-head p {
  max-width: 980px;
  color: var(--erp-muted);
  font-size: 13px;
  line-height: 1.55;
}

button {
  min-height: 34px;
  border-color: var(--erp-border-strong);
  border-radius: 10px;
  background: #fff;
  color: #344054;
  font-size: 12px;
  font-weight: 820;
  box-shadow: none;
}

button:hover:not(:disabled) {
  border-color: #b8c2d8;
  background: #f8faff;
  box-shadow: var(--erp-shadow-soft);
  transform: none;
}

button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--erp-primary), #4f46e5);
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.16);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--erp-primary-strong), #4338ca);
}

button.danger {
  border-color: #fecdca;
  background: var(--erp-danger-soft);
  color: var(--erp-danger);
}

input,
select,
textarea {
  border-color: var(--erp-border-strong);
  background: #fff;
  color: var(--erp-text);
}

input,
select {
  height: 36px;
  border-radius: 10px;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #84adff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

label {
  color: #475467;
  font-size: 12px;
  font-weight: 820;
}

.toolbar,
.panel,
.empty-panel,
.message-context,
.message-history,
.reply-box,
.order-card,
.order-detail-panel,
.record-card,
.store-card,
.memo-panel,
.memo-editor,
.summary-item,
.refund-line,
.refund-order-info div {
  border: 1px solid var(--erp-border);
  background: var(--erp-surface);
  box-shadow: var(--erp-shadow-soft);
}

.toolbar,
.order-filter-panel {
  padding: 14px;
  border-radius: 14px;
}

.panel,
.empty-panel {
  padding: 14px;
  border-radius: 14px;
}

.panel-head h2,
.conversation-head h2,
.modal h2,
.modal-title-row h2 {
  color: var(--erp-text);
  font-size: 15px;
  font-weight: 900;
}

.panel-head {
  min-height: 34px;
  margin-bottom: 12px;
}

.status,
.badge,
.thread-badge,
.dialog-chip {
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #667085;
  font-size: 11px;
}

.status.needs-reply,
.thread-badge.needs-reply {
  border-color: #fedf89;
  background: var(--erp-warning-soft);
  color: var(--erp-warning);
}

.status.replied,
.thread-badge.replied,
.badge.uploaded {
  background: var(--erp-success-soft);
  color: var(--erp-success);
}

.status.ignored {
  background: #f2f4f7;
  color: #667085;
}

.messages-layout {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
}

.message-toolbar {
  grid-template-columns: minmax(180px, 240px) minmax(320px, 1fr) minmax(150px, 180px) auto;
}

.message-list-panel,
.conversation-panel {
  min-height: calc(100vh - 188px);
}

.conversation-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  grid-template-areas:
    "head head"
    "history context"
    "reply context";
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 12px;
}

.conversation-head {
  grid-area: head;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--erp-border);
}

.message-context {
  grid-area: context;
  display: block;
  overflow: auto;
  padding: 14px;
  border-radius: 14px;
  background: #fbfcff;
  box-shadow: none;
}

.message-context > div {
  padding: 10px 0;
  border-bottom: 1px solid var(--erp-border);
}

.message-context > div:last-child {
  border-bottom: 0;
}

.message-context span {
  color: #667085;
  font-size: 11px;
  font-weight: 800;
}

.message-context strong,
.tracking-button,
.product-link {
  color: var(--erp-text);
  font-size: 13px;
  line-height: 1.45;
}

.message-history {
  grid-area: history;
  min-height: 360px;
  max-height: none;
  padding: 14px;
  border-radius: 14px;
  background: #f8faff;
}

.reply-box {
  grid-area: reply;
  padding: 12px;
  border-radius: 14px;
}

.thread-card {
  min-height: 84px;
  padding: 11px 12px;
  border: 1px solid var(--erp-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
}

.thread-card:hover:not(:disabled),
.thread-card.active {
  border-color: #bcd2ff;
  background: var(--erp-primary-soft);
  box-shadow: var(--erp-shadow-soft);
}

.thread-card strong {
  color: var(--erp-text);
  font-size: 14px;
}

.thread-topic {
  color: #475467;
}

.message-bubble {
  border-radius: 14px;
  background: #fff;
}

.message-row.mine .message-bubble {
  border-color: #d9d6ff;
  background: var(--erp-purple-soft);
}

.message-body {
  font-size: 13px;
  line-height: 1.62;
}

.reply-box textarea {
  min-height: 88px;
  font-size: 13px;
}

.order-filter-grid,
.toolbar {
  align-items: end;
}

.orders-table-head {
  border-radius: 10px;
  background: #f8faff;
}

.order-card {
  min-height: 108px;
  border-radius: 12px;
  box-shadow: none;
}

.order-identity {
  background: #f8faff;
  border: 1px solid #eef2ff;
}

.order-detail-panel,
.record-card,
.store-card,
.summary-item,
.detail-card,
.order-line-card,
.refund-line {
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.records-list,
.store-list,
.order-line-list,
.refund-lines {
  gap: 8px;
}

.settings-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.form,
.record-search {
  gap: 12px;
}

.memo-panel {
  gap: 12px;
}

.memo-toolbar {
  border-color: var(--erp-border);
  background: #f8faff;
}

.memo-editor {
  min-height: 560px;
  border-radius: 12px;
  box-shadow: none;
}

.modal-backdrop {
  background: rgba(15, 23, 42, 0.36);
}

.modal {
  border-color: var(--erp-border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.22);
}

@media (max-width: 1360px) {
  .conversation-panel {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "context"
      "history"
      "reply";
  }

  .message-context {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
  }

  .message-context > div {
    border-bottom: 0;
  }
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .workspace-actions {
    display: none;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Strict version-B customer service workspace structure. */
#messages-view .page-head {
  margin-bottom: 10px;
}

#messages-view .page-head h1 {
  font-size: 24px;
}

#messages-view .page-head p {
  font-size: 12px;
}

#messages-view .message-toolbar {
  display: grid;
  grid-template-columns: 210px minmax(300px, 1fr) 168px 104px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
}

#messages-view .message-toolbar label {
  gap: 4px;
}

#messages-view .message-toolbar input,
#messages-view .message-toolbar select {
  height: 32px;
}

#messages-view .messages-workbench {
  display: grid;
  grid-template-columns: 300px minmax(460px, 1fr) 330px;
  gap: 12px;
  align-items: stretch;
  min-height: calc(100vh - 190px);
}

#messages-view .message-list-panel,
#messages-view .conversation-panel,
#messages-view .message-context-panel {
  min-height: calc(100vh - 190px);
  margin-bottom: 0;
}

#messages-view .message-list-panel {
  padding: 12px;
}

#messages-view .message-list-panel .panel-head {
  align-items: start;
  margin-bottom: 10px;
}

#messages-view .message-list-panel .panel-head h2,
#messages-view .message-context-panel .panel-head h2 {
  font-size: 14px;
}

#messages-view .thread-list {
  gap: 7px;
  max-height: calc(100vh - 272px);
  overflow: auto;
  padding-right: 2px;
}

#messages-view .thread-card {
  position: relative;
  min-height: 72px;
  padding: 10px 10px 10px 13px;
  border-radius: 11px;
}

#messages-view .thread-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}

#messages-view .thread-card.active::before {
  background: var(--erp-primary);
}

#messages-view .thread-badge {
  min-height: 20px;
  font-size: 10px;
}

#messages-view .thread-time {
  top: 11px;
  right: 10px;
  font-size: 10px;
}

#messages-view .thread-card strong {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.22;
}

#messages-view .thread-topic {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.32;
}

#messages-view .thread-meta {
  margin-top: 3px;
  font-size: 10px;
}

#messages-view .conversation-panel {
  grid-template-columns: 1fr;
  grid-template-areas:
    "head"
    "history"
    "reply";
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
}

#messages-view .conversation-head {
  grid-area: head;
  align-items: start;
  min-height: 78px;
  padding-bottom: 10px;
}

#messages-view .conversation-head h2 {
  font-size: 20px;
  line-height: 1.2;
}

#messages-view .conversation-head p {
  max-width: 760px;
  margin-top: 5px;
  font-size: 12px;
}

#messages-view .conversation-tools {
  align-items: center;
  gap: 7px;
}

#messages-view .conversation-tools button {
  min-height: 32px;
}

#messages-view .message-history {
  grid-area: history;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 14px;
}

#messages-view .message-bubble {
  max-width: min(78%, 620px);
}

#messages-view .reply-box {
  grid-area: reply;
  position: sticky;
  bottom: 0;
  z-index: 1;
}

#messages-view .reply-box textarea {
  min-height: 82px;
}

#messages-view .reply-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#messages-view .reply-actions select {
  width: 112px;
  margin-right: auto;
}

#messages-view .message-context-panel {
  padding: 12px;
}

#messages-view .message-context-panel .panel-head {
  margin-bottom: 10px;
}

#messages-view .message-context {
  display: block;
  height: calc(100vh - 258px);
  overflow: auto;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#messages-view .message-context.empty-state {
  display: grid;
  place-items: center;
  height: calc(100vh - 258px);
  border: 1px dashed var(--erp-border-strong);
  border-radius: 12px;
  background: #fbfcff;
}

#messages-view .message-context > div {
  padding: 11px 0;
  border-bottom: 1px solid var(--erp-border);
}

#messages-view .message-context > .context-wide,
#messages-view .message-context > .context-card-head {
  grid-column: auto;
}

#messages-view .message-context .context-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#messages-view .message-context .context-card-head button,
#messages-view .message-context #refund-open {
  min-height: 30px;
}

#messages-view .message-context span {
  display: block;
  margin-bottom: 5px;
  color: #667085;
  font-size: 11px;
  font-weight: 850;
}

#messages-view .message-context strong {
  display: block;
  color: var(--erp-text);
  font-size: 13px;
  line-height: 1.48;
  white-space: normal;
}

#messages-view .message-context .product-list {
  display: grid;
  gap: 6px;
}

#messages-view .tracking-button,
#messages-view .product-link {
  width: 100%;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--erp-primary-strong);
  box-shadow: none;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
}

#messages-view .tracking-button:hover,
#messages-view .product-link:hover {
  background: transparent;
  box-shadow: none;
  text-decoration: underline;
}

@media (max-width: 1480px) {
  #messages-view .messages-workbench {
    grid-template-columns: 286px minmax(420px, 1fr) 310px;
  }
}

@media (max-width: 1240px) {
  #messages-view .messages-workbench {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  #messages-view .message-context-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

  #messages-view .message-context,
  #messages-view .message-context.empty-state {
    height: auto;
    max-height: 260px;
  }
}

/* Allroot-style SaaS ERP polish: compact teal system, high-density work surfaces. */
:root {
  --bg: #f5f8f7;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --line: #dfe9e7;
  --soft-line: #edf3f2;
  --text: #182422;
  --muted: #6d7977;
  --label: #53615f;
  --primary: #159285;
  --primary-strong: #0a7068;
  --primary-dark: #08615a;
  --active: #e8f6f3;
  --danger: #a45a58;
  --danger-bg: #fff7f5;
  --danger-line: #eed9d4;
  --field: #fbfdfd;
  --field-line: #dce8e5;
  --warning: #7a520f;
  --warning-bg: #fff8ea;
  --warning-line: #ead39f;
  --shadow: 0 24px 70px rgba(22, 45, 42, 0.08);
  --button-shadow: 0 14px 24px rgba(18, 160, 147, 0.18);
  --erp-bg: var(--bg);
  --erp-surface: #ffffff;
  --erp-surface-soft: #fbfdfd;
  --erp-border: var(--line);
  --erp-border-strong: var(--field-line);
  --erp-text: var(--text);
  --erp-muted: var(--muted);
  --erp-subtle: #8a9694;
  --erp-primary: var(--primary);
  --erp-primary-strong: var(--primary-strong);
  --erp-primary-soft: var(--active);
  --erp-purple: var(--primary);
  --erp-purple-soft: var(--active);
  --erp-success: #167044;
  --erp-success-soft: #eaf7f0;
  --erp-warning: var(--warning);
  --erp-warning-soft: var(--warning-bg);
  --erp-danger: var(--danger);
  --erp-danger-soft: var(--danger-bg);
  --erp-shadow: var(--shadow);
  --erp-shadow-soft: 0 10px 28px rgba(22, 45, 42, 0.06);
}

body {
  background: linear-gradient(180deg, #f8fbfa 0%, #f5f8f7 42%, #f2f7f6 100%);
  color: var(--text);
  font-size: 13px;
}

.app {
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 16px;
  border-right-color: var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 10px 0 32px rgba(22, 45, 42, 0.04);
}

.brand {
  margin-bottom: 22px;
  padding-bottom: 14px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  box-shadow: 0 12px 22px rgba(21, 146, 133, 0.18);
}

.brand strong {
  color: var(--text);
  font-size: 19px;
}

.brand span {
  color: var(--muted);
}

.nav-section {
  color: #7d8987;
  font-size: 11px;
}

.nav {
  color: var(--muted);
}

.nav:hover:not(:disabled) {
  background: rgba(232, 246, 243, 0.62);
  color: var(--primary-strong);
}

.nav.active {
  border-color: rgba(16, 115, 107, 0.08);
  background: var(--active);
  color: var(--primary-strong);
}

.nav.active::before {
  background: var(--primary);
}

.security-note,
.workspace-hint {
  border-color: #e4eeec;
  background: #f7fbfa;
  color: var(--muted);
}

.content {
  padding: 26px 32px 32px;
}

.workspace-topbar {
  margin: -26px -32px 22px;
  padding: 10px 32px;
  border-bottom-color: var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.workspace-tab {
  min-height: 32px;
  padding: 0 12px;
  color: var(--muted);
}

.workspace-tab.active {
  background: var(--active);
  color: var(--primary-strong);
}

.workspace-avatar,
button.primary {
  background: linear-gradient(135deg, #0b8f83, #12b9a7);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #087b72, #0fae9d);
}

.page-head {
  margin-bottom: 12px;
}

.page-head h1 {
  font-size: 30px;
  font-weight: 900;
}

.page-head p {
  color: var(--muted);
  font-size: 13px;
}

.toolbar,
.order-filter-panel {
  padding: 12px;
  border-radius: 14px;
}

input,
select {
  height: 38px;
  border-color: var(--field-line);
  background: var(--field);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(21, 146, 133, 0.55);
  box-shadow: 0 0 0 4px rgba(21, 146, 133, 0.10);
}

button {
  min-height: 36px;
  border-color: var(--field-line);
  border-radius: 12px;
  color: var(--text);
  font-size: 13px;
}

button:hover:not(:disabled) {
  border-color: #c8dcda;
  background: #fbfdfd;
}

button.danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

.panel,
.empty-panel,
.toolbar,
.message-context,
.message-history,
.reply-box,
.order-card,
.order-detail-panel,
.record-card,
.store-card,
.memo-panel,
.memo-editor,
.summary-item,
.refund-line,
.refund-order-info div {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(22, 45, 42, 0.05);
}

.panel,
.empty-panel {
  border-radius: 16px;
}

.panel-head h2,
.conversation-head h2,
.modal h2,
.modal-title-row h2 {
  font-size: 17px;
}

.status,
.badge,
.thread-badge,
.dialog-chip {
  background: #eff5f4;
  color: var(--muted);
}

.status.needs-reply,
.thread-badge.needs-reply {
  border-color: var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning);
}

.status.replied,
.thread-badge.replied,
.badge.uploaded {
  background: #e9f7ef;
  color: #167044;
}

#messages-view .message-toolbar {
  grid-template-columns: 210px minmax(320px, 1fr) 168px 104px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 14px;
}

#messages-view .messages-workbench {
  grid-template-columns: 308px minmax(480px, 1fr) 336px;
  gap: 12px;
}

#messages-view .message-list-panel,
#messages-view .conversation-panel,
#messages-view .message-context-panel {
  min-height: calc(100vh - 196px);
}

#messages-view .thread-card {
  min-height: 70px;
  border-radius: 12px;
}

#messages-view .thread-card:hover:not(:disabled),
#messages-view .thread-card.active {
  border-color: rgba(21, 146, 133, 0.28);
  background: var(--active);
}

#messages-view .thread-card.active::before {
  background: var(--primary);
}

#messages-view .conversation-head h2 {
  font-size: 20px;
}

#messages-view .conversation-head {
  min-height: 72px;
}

#messages-view .message-history {
  background: linear-gradient(180deg, #fbfdfd, #f7faf9);
}

#messages-view .message-row.mine .message-bubble {
  border-color: #cfe8e4;
  background: var(--active);
}

#messages-view .message-context {
  height: calc(100vh - 264px);
}

#messages-view .tracking-button,
#messages-view .product-link {
  color: var(--primary-strong);
}

.orders-table-head {
  background: #f7fbfa;
}

.order-identity {
  background: #f7fbfa;
  border-color: #e4eeec;
}

.order-tab.active {
  border-color: rgba(21, 146, 133, 0.16);
  background: var(--active);
  color: var(--primary-strong);
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-item,
.detail-card,
.order-line-card,
.record-card,
.refund-line,
.refund-order-info div,
.store-card {
  background: #fff;
}

.memo-toolbar {
  background: #f7fbfa;
}

.memo-editor blockquote {
  border-left-color: var(--primary);
  background: rgba(21, 146, 133, 0.07);
}

.modal {
  border-color: var(--line);
}

@media (max-width: 1480px) {
  #messages-view .messages-workbench {
    grid-template-columns: 290px minmax(440px, 1fr) 316px;
  }
}

@media (max-width: 1240px) {
  #messages-view .messages-workbench {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

/* Product Manager alignment: blue-white SaaS ERP surface from cross-border-product-manager. */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --line: #e6eaf2;
  --soft-line: #eef2f7;
  --text: #172033;
  --muted: #758197;
  --label: #536078;
  --primary: #2f6bff;
  --primary-strong: #1746b8;
  --primary-dark: #143f9f;
  --active: #edf4ff;
  --danger: #c2414b;
  --danger-bg: #fff1f2;
  --danger-line: #ffd7dc;
  --field: #ffffff;
  --field-line: #dce3ee;
  --warning: #9a6200;
  --warning-bg: #fff7e6;
  --warning-line: #f4d28c;
  --success: #17845f;
  --success-bg: #eaf8f1;
  --shadow: 0 1px 2px rgba(20, 28, 45, 0.04), 0 10px 28px rgba(20, 28, 45, 0.05);
  --button-shadow: none;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
}

body {
  min-width: 1180px;
  background:
    linear-gradient(180deg, rgba(237, 244, 255, 0.78) 0, rgba(245, 247, 251, 0) 230px),
    var(--bg);
  color: var(--text);
  font-size: 12px;
}

button,
.button {
  min-height: 30px;
  padding: 0 11px;
  border-color: #d8e0ec;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #26324a;
  box-shadow: none;
  font-size: 12px;
  font-weight: 760;
  transform: none;
}

button:hover:not(:disabled),
.button:hover {
  border-color: #b8c6dc;
  background: #f8fbff;
  box-shadow: none;
  transform: none;
}

button.primary,
.button.primary,
.primary {
  border-color: #265be8;
  background: #2f6bff;
  color: #fff;
  box-shadow: none;
}

button.primary:hover:not(:disabled),
.button.primary:hover,
.primary:hover {
  border-color: #1f50d6;
  background: #255deb;
}

button.danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

input,
select,
textarea {
  border-color: var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font-size: 12px;
}

input,
select {
  height: 32px;
  padding: 0 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(47, 107, 255, 0.58);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.11);
}

label {
  gap: 6px;
  color: var(--label);
  font-size: 11px;
  font-weight: 780;
}

.app {
  grid-template-columns: 238px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 238px;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.brand {
  gap: 10px;
  margin: 0 0 14px;
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--soft-line);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: 0 8px 18px rgba(20, 28, 45, 0.13);
}

.brand strong {
  color: #111827;
  font-size: 17px;
  line-height: 1.1;
  font-weight: 860;
}

.brand span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.nav-section {
  display: block;
  margin: 14px 0 4px;
  padding: 0 10px;
  color: #9aa4b6;
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.08em;
}

.sidebar .nav {
  position: relative;
  width: 100%;
  height: 32px;
  min-height: 32px;
  margin: 0 0 4px;
  padding: 0 10px 0 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #5d687d;
  font-size: 12px;
  font-weight: 720;
  text-align: left;
}

.sidebar .nav::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #c6cfdd;
  transform: translateY(-50%);
}

.sidebar .nav:hover {
  border-color: #e2e8f3;
  background: #f7faff;
}

.sidebar .nav.active {
  border-color: #d8e6ff;
  background: var(--active);
  color: var(--primary-strong);
  font-weight: 820;
}

.sidebar .nav.active::before {
  background: var(--primary);
}

.security-note {
  margin-top: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfcff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.content {
  padding: 24px 28px 30px;
}

.workspace-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -24px -28px 18px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(14px);
}

.workspace-tabs {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  height: 30px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #5d687d;
  font-size: 12px;
  font-weight: 780;
}

.workspace-tab.active {
  border-color: #d8e6ff;
  background: var(--active);
  color: var(--primary-strong);
}

.workspace-hint {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f7faff;
  color: var(--muted);
  font-size: 11px;
}

.workspace-avatar {
  background: #2f6bff;
  color: #fff;
  box-shadow: none;
}

.page-head {
  margin-bottom: 16px;
}

.page-head h1 {
  color: #111827;
  font-size: 23px;
  line-height: 1.18;
  font-weight: 860;
}

.page-head p {
  max-width: 780px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.toolbar,
.order-filter-panel,
.panel,
.empty-panel,
.modal,
.memo-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow);
}

.toolbar,
.order-filter-panel {
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

.panel-head {
  margin-bottom: 12px;
}

.panel-head h2,
.conversation-head h2,
.modal h2,
.modal-title-row h2 {
  color: #111827;
  font-size: 14px;
  font-weight: 840;
}

.status,
.badge,
.thread-badge,
.dialog-chip {
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f1f4f8;
  color: #687388;
  font-size: 11px;
  font-weight: 760;
}

.status.needs-reply,
.thread-badge.needs-reply {
  border-color: var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning);
}

.status.replied,
.thread-badge.replied,
.badge.uploaded,
.status.success {
  background: var(--success-bg);
  color: var(--success);
}

#messages-view .message-toolbar {
  grid-template-columns: 210px minmax(280px, 1fr) 150px 96px;
}

#messages-view .messages-workbench {
  display: grid;
  grid-template-columns: 312px minmax(520px, 1fr) 344px;
  gap: 12px;
  align-items: stretch;
}

#messages-view .message-list-panel,
#messages-view .conversation-panel,
#messages-view .message-context-panel {
  min-height: calc(100vh - 194px);
}

#messages-view .message-list-panel,
#messages-view .conversation-panel,
#messages-view .message-context-panel {
  overflow: hidden;
}

#messages-view .thread-list {
  gap: 8px;
}

#messages-view .thread-card {
  min-height: 76px;
  padding: 12px;
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

#messages-view .thread-card:hover:not(:disabled),
#messages-view .thread-card.active {
  border-color: #cfe0ff;
  background: #f4f8ff;
  box-shadow: none;
}

#messages-view .thread-card.active::before {
  background: var(--primary);
}

#messages-view .thread-card strong {
  font-size: 14px;
}

#messages-view .thread-topic,
#messages-view .thread-meta,
#message-refresh-time {
  font-size: 11px;
}

#messages-view .conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto;
  gap: 12px;
}

#messages-view .conversation-head {
  align-items: flex-start;
  min-height: 60px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--soft-line);
}

#messages-view .conversation-head h2 {
  font-size: 19px;
}

#messages-view .conversation-head p {
  color: var(--muted);
  font-size: 12px;
}

.conversation-tools {
  gap: 8px;
}

#messages-view .message-history {
  max-height: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fbfcff;
}

#messages-view .message-bubble {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

#messages-view .message-row.mine .message-bubble {
  border-color: #cfe0ff;
  background: #f4f8ff;
}

#messages-view .message-meta {
  color: var(--muted);
  font-size: 11px;
}

#messages-view .message-body {
  font-size: 13px;
  line-height: 1.62;
}

#messages-view .reply-box {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: none;
}

#messages-view .reply-box textarea {
  min-height: 82px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

#messages-view .message-context {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
  height: calc(100vh - 252px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#messages-view .message-context > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfcff;
}

#messages-view .message-context .context-card-head {
  order: -2;
  display: flex;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  background: transparent;
}

#messages-view .message-context .context-wide {
  grid-column: auto;
}

#messages-view .message-context span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

#messages-view .message-context strong {
  margin-top: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  white-space: normal;
}

#messages-view .tracking-button,
#messages-view .product-link {
  color: var(--primary-strong);
  font-weight: 800;
}

.orders-workspace {
  display: grid;
  gap: 10px;
}

.orders-list {
  display: grid;
  gap: 0;
  overflow: auto;
}

.orders-table-head {
  display: grid;
  grid-template-columns: 158px minmax(250px, 1.55fr) 112px 132px 136px 146px 112px 126px;
  align-items: center;
  min-width: 1180px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: #f8fafc;
  color: #667085;
  font-size: 10px;
  font-weight: 820;
}

.order-card {
  display: grid;
  grid-template-columns: 158px minmax(250px, 1.55fr) 112px 132px 136px 146px 112px 126px;
  align-items: center;
  min-width: 1180px;
  min-height: 86px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.order-card:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.order-identity {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.order-identity strong {
  color: #111827;
  font-size: 15px;
  line-height: 1.25;
}

.order-identity span {
  display: none;
}

.order-product-cell,
.order-meta-cell {
  min-width: 0;
}

.order-product-cell strong {
  display: -webkit-box;
  overflow: hidden;
  color: #26324a;
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.order-product-cell span,
.order-meta-cell span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-meta-cell strong {
  overflow: hidden;
  color: #26324a;
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-width: 0;
}

.order-actions button {
  width: 100%;
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.order-tabs {
  gap: 6px;
  margin-bottom: 0;
}

.order-tab {
  height: 28px;
  min-height: 28px;
  border-radius: 999px;
}

.order-tab.active {
  border-color: #d8e6ff;
  background: var(--active);
  color: var(--primary-strong);
}

.order-detail-panel,
.detail-card,
.order-line-card,
.summary-item,
.record-card,
.refund-line,
.refund-order-info div,
.store-card,
.memo-editor {
  border-color: var(--line);
  background: #fff;
  box-shadow: none;
}

.order-detail-grid span,
.summary-item span,
.record-card span,
.detail-card span {
  color: var(--muted);
  font-size: 11px;
}

.order-detail-grid strong,
.summary-item strong,
.record-card strong,
.detail-card strong {
  color: #26324a;
  font-size: 12px;
}

.memo-toolbar {
  border-color: var(--line);
  background: #fbfcff;
}

.memo-editor blockquote {
  border-left-color: var(--primary);
  background: rgba(47, 107, 255, 0.07);
}

.modal-backdrop {
  background: rgba(15, 23, 42, 0.26);
  backdrop-filter: blur(10px);
}

.modal {
  border-color: var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(20, 28, 45, 0.18);
}

.refund-line {
  grid-template-columns: 70px minmax(170px, 1.15fr) 64px 106px 104px minmax(150px, 0.9fr) minmax(170px, 1fr);
}

.refund-operation-reason-wrap {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.operation-refund-reason-other {
  width: 100%;
  min-width: 0;
}

.refund-platform-note {
  min-width: 0;
}

.refund-line-lock {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.refund-line.is-locked {
  background: #f7faf9;
}

@media (max-width: 1040px) {
  .refund-line {
    grid-template-columns: 76px minmax(180px, 1fr) 78px minmax(130px, 1fr);
  }

  .refund-product,
  .refund-reason-wrap,
  .refund-operation-reason-wrap,
  .refund-platform-note {
    grid-column: span 2;
  }
}

@media (max-width: 1480px) {
  #messages-view .messages-workbench {
    grid-template-columns: 292px minmax(460px, 1fr) 316px;
  }

  .orders-table-head,
  .order-card {
    grid-template-columns: 148px minmax(230px, 1.45fr) 104px 120px 128px 138px 104px 118px;
    min-width: 1090px;
  }
}

@media (max-width: 1240px) {
  #messages-view .messages-workbench {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  #messages-view .message-context-panel {
    display: none;
  }
}


/* Product manager UI alignment overrides */


/* Final product-manager strict layout pass */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --line: #e6eaf2;
  --soft-line: #eef2f7;
  --text: #172033;
  --muted: #758197;
  --label: #536078;
  --primary: #2f6bff;
  --primary-strong: #1746b8;
  --primary-dark: #143f9f;
  --active: #edf4ff;
  --field: #ffffff;
  --field-line: #dce3ee;
  --shadow: 0 1px 2px rgba(20, 28, 45, 0.04), 0 12px 30px rgba(20, 28, 45, 0.055);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
}

body {
  min-width: 1220px;
  background:
    linear-gradient(180deg, rgba(238, 244, 255, 0.92) 0, rgba(245, 247, 251, 0.94) 245px),
    #f5f7fb;
  font-size: 12px;
}

.app {
  grid-template-columns: 238px minmax(0, 1fr);
}

.workspace-topbar {
  display: none;
}

.content {
  padding: 24px 28px 30px;
}

.sidebar {
  width: 238px;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.98);
}

.page-head {
  margin-bottom: 16px;
}

.page-head h1 {
  font-size: 24px;
  letter-spacing: 0;
}

.page-head p {
  font-size: 12px;
  color: var(--muted);
}

#messages-view .message-toolbar {
  display: grid;
  grid-template-columns: 220px minmax(360px, 1fr) 160px 104px;
  align-items: end;
  padding: 12px 14px;
  border-radius: 14px;
}

#messages-view .messages-workbench {
  display: grid;
  grid-template-columns: 320px minmax(560px, 1fr) 360px;
  gap: 12px;
  align-items: stretch;
}

#messages-view .message-list-panel,
#messages-view .conversation-panel,
#messages-view .message-context-panel {
  min-height: calc(100vh - 180px);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

#messages-view .message-list-panel {
  padding: 14px;
}

#messages-view .conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(330px, 1fr) auto;
  gap: 12px;
  padding: 14px;
}

#messages-view .message-context-panel {
  padding: 14px;
}

#messages-view .message-context-panel .panel-head {
  margin-bottom: 12px;
}

#messages-view .panel-head h2,
#messages-view .conversation-head h2 {
  font-size: 15px;
  color: #111827;
}

#messages-view .conversation-head h2 {
  font-size: 19px;
}

#messages-view .thread-list {
  gap: 8px;
}

#messages-view .thread-card {
  position: relative;
  min-height: 82px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
}

#messages-view .thread-card.active,
#messages-view .thread-card:hover:not(:disabled) {
  border-color: #cfe0ff;
  background: #f4f8ff;
}

#messages-view .thread-card.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}

#messages-view .thread-card strong {
  font-size: 14px;
  line-height: 1.25;
}

#messages-view .thread-topic,
#messages-view .thread-meta,
#messages-view .thread-time {
  font-size: 11px;
  line-height: 1.35;
}

#messages-view .message-history {
  max-height: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
}

#messages-view .message-bubble {
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: none;
}

#messages-view .message-row.mine .message-bubble {
  border-color: #cfe0ff;
  background: #f4f8ff;
}

#messages-view .reply-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: none;
}

#messages-view .reply-box textarea {
  min-height: 82px;
  font-size: 13px;
}

#messages-view .message-context {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  height: calc(100vh - 238px);
  overflow: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#messages-view .message-context.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  height: auto;
  padding: 22px;
  border: 1px dashed #dce3ee;
  border-radius: 12px;
  background: #fbfcff;
  color: var(--muted);
  text-align: center;
}

#messages-view .message-context > div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}

#messages-view .message-context .context-card-head {
  display: flex;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  background: transparent;
}

#messages-view .message-context span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#messages-view .message-context strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.48;
  white-space: normal;
}

#messages-view .message-context .tracking-list,
#messages-view .message-context .product-list {
  display: grid;
  gap: 7px;
}

#messages-view .tracking-button,
#messages-view .product-link {
  display: block;
  width: 100%;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  text-align: left;
  text-decoration: none;
  white-space: normal;
  box-shadow: none;
}

#messages-view .tracking-button:hover,
#messages-view .product-link:hover {
  background: transparent;
  color: var(--primary-dark);
  text-decoration: underline;
  transform: none;
}

#messages-view .product-link.disabled {
  color: #26324a;
  font-weight: 760;
}

.order-filter-grid {
  gap: 10px;
}

.orders-list {
  overflow-x: auto;
}

.orders-table-head,
.order-card {
  grid-template-columns: 142px minmax(300px, 1.8fr) 96px 112px 128px 136px 104px 116px;
  min-width: 1120px;
}

.order-card {
  min-height: 74px;
}

.order-identity strong {
  font-size: 14px;
}

.order-product-cell strong,
.order-meta-cell strong {
  font-size: 12px;
}

.order-actions button {
  min-height: 26px;
}

@media (max-width: 1480px) {
  #messages-view .messages-workbench {
    grid-template-columns: 300px minmax(500px, 1fr) 330px;
  }

  .orders-table-head,
  .order-card {
    grid-template-columns: 132px minmax(270px, 1.65fr) 90px 104px 120px 128px 98px 108px;
    min-width: 1040px;
  }
}

@media (max-width: 1240px) {
  #messages-view .messages-workbench {
    grid-template-columns: 280px minmax(0, 1fr) 300px;
  }

  #messages-view .message-context-panel {
    display: block;
  }
}


/* Context product cards */
#messages-view .context-products-panel,
#messages-view .context-total-panel,
#messages-view .context-actions-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

#messages-view .context-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--soft-line);
}

#messages-view .context-section-head span,
#messages-view .context-actions-panel > span {
  color: #111827;
  font-size: 13px;
  font-weight: 850;
}

#messages-view .context-product-list {
  display: grid;
  gap: 0;
}

#messages-view .context-product-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--soft-line);
}

#messages-view .context-product-card:last-child {
  border-bottom: 0;
}

#messages-view .context-product-image {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 10px;
}

#messages-view .context-product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#messages-view .context-product-info {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

#messages-view .context-product-name,
#messages-view .context-product-name.product-link {
  display: -webkit-box;
  overflow: hidden;
  padding: 0;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.32;
  text-align: left;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#messages-view .context-product-info > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messages-view .context-product-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

#messages-view .context-product-foot span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

#messages-view .context-product-foot strong {
  margin: 0;
  color: #26324a;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

#messages-view .context-total-panel {
  display: grid;
  gap: 8px;
}

#messages-view .context-total-panel > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#messages-view .context-total-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

#messages-view .context-total-panel strong {
  margin: 0;
  color: #26324a;
  font-size: 12px;
  white-space: nowrap;
}

#messages-view .context-total-panel .context-total-amount {
  color: var(--primary);
  font-weight: 900;
}

#messages-view .context-actions-panel {
  display: grid;
  gap: 8px;
}

#messages-view .context-actions-panel button {
  width: 100%;
  min-height: 34px;
}

#messages-view .context-empty-line {
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Minimal side-column scroll repair: keep the original layout, only cap left/right columns. */
#messages-view .message-list-panel,
#messages-view .message-context-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 260px);
  min-height: 620px;
  overflow: hidden;
}

#messages-view .message-list-panel .panel-head,
#messages-view .message-context-panel .panel-head {
  flex: 0 0 auto;
}

#messages-view .thread-list,
#messages-view .message-context {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

#messages-view .message-context.empty-state {
  height: auto;
}

/* Message list readability repair: keep cards compact, but give each field readable room. */
#messages-view .thread-card {
  min-height: 148px;
  height: auto;
  padding: 16px 16px 15px 18px;
  overflow: hidden;
}

#messages-view .thread-card strong {
  display: block;
  padding-right: 92px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messages-view .thread-topic {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
  text-overflow: clip;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#messages-view .thread-customer {
  display: block;
  overflow: hidden;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messages-view .thread-preview {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
  text-overflow: clip;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
