:root {
  --bg: #f7f8fa;
  --text: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --panel: #ffffff;
  --panel-2: #f2f4f7;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #a16207;
  --warn-bg: #fefce8;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --disabled: #667085;
  --disabled-bg: #f2f4f7;
  --unknown: #475467;
  --unknown-bg: #f2f4f7;
  --accent: #0f766e;
  --accent-strong: #0b4f4a;
  --shadow: 0 16px 42px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(90deg, #fff 0, #fff 276px, var(--bg) 276px);
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  height: 100vh;
  min-height: 0;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.brand {
  padding: 0 8px;
}

.brand-title {
  color: var(--text);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.brand.is-prod .brand-title {
  color: #db2777;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 30px;
  line-height: 1.12;
}

h3 {
  font-size: 18px;
  line-height: 1.2;
}

.subtle,
.updated,
.metric-label,
.nav-meta,
.empty {
  color: var(--muted);
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  overflow: auto;
}

.nav-item,
.summary-row,
.cron-row,
.secondary {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 9px 8px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #f8fafc;
  border-color: #eaecf0;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.nav-label {
  font-weight: 800;
}

.nav-meta {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-state {
  font-size: 12px;
  font-weight: 800;
}

.sidebar-foot {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
}

.user-menu-wrap {
  position: relative;
}

.user-menu-button {
  display: grid;
  width: 100%;
  gap: 4px;
  min-height: 54px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.user-menu-button:disabled {
  cursor: default;
}

.user-menu-button:not(:disabled)::after {
  content: "管理";
  width: fit-content;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  background: #f0fdfa;
}

.user-name {
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
}

.user-role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.user-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 15;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.user-menu[hidden] {
  display: none;
}

.user-menu button {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.user-menu button:hover {
  background: #f8fafc;
}

.workspace {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 30px 34px 44px;
}

.workspace-view {
  display: grid;
  gap: 22px;
  animation: enter 220ms ease both;
}

.login-panel {
  display: grid;
  gap: 22px;
  width: min(460px, 100%);
  margin: 8vh auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(21, 25, 28, 0.08);
}

.auth-page {
  height: auto;
  min-height: 100vh;
  overflow: auto;
  background: #111316;
}

.auth-page .app-shell {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow: visible;
  background: #111316;
}

.auth-page .sidebar {
  display: none;
}

.auth-page .workspace {
  min-height: 100vh;
  padding: 0;
}

.auth-page .workspace-view {
  display: grid;
  min-height: 100vh;
  gap: 0;
  animation: enter 260ms ease both;
}

.auth-page .login-panel {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  align-items: center;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: clamp(28px, 7vw, 86px);
  border: 0;
  border-radius: 0;
  background: linear-gradient(90deg, #111316, #18201f);
  color: #f8fafc;
  box-shadow: none;
}

.auth-page .login-panel > div {
  max-width: 620px;
}

.auth-page .login-panel .eyebrow {
  color: #5eead4;
}

.auth-page .login-panel h2 {
  max-width: 540px;
  color: #fff;
  font-size: 56px;
  line-height: 0.98;
}

.auth-page .login-panel .subtle {
  max-width: 430px;
  margin-top: 18px;
  color: #cbd5e1;
  font-size: 15px;
}

.auth-page .login-form {
  align-self: center;
  gap: 16px;
  padding: 26px;
  border: 1px solid rgba(226, 232, 240, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.34);
}

.auth-page .login-form .empty {
  margin: 0;
  padding: 0;
  color: var(--bad);
}

.auth-page .login-form .secondary {
  width: 100%;
  color: #fff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.login-panel h2 {
  font-size: 30px;
}

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

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.login-form input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--accent);
}

.view-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

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

.dxm-reminder-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dxm-urgent-order-button {
  min-width: 136px;
  border-color: #fecaca;
  color: #991b1b;
  background: #fef2f2;
  font-weight: 900;
}

.dxm-urgent-order-button:hover,
.dxm-urgent-order-button:focus-visible {
  border-color: #fca5a5;
  background: #fee2e2;
}

.dxm-package-reason-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
}

.reason-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.reason-filter-chip span {
  color: var(--muted);
  font-weight: 800;
}

.reason-filter-chip.active {
  border-color: #fca5a5;
  color: #991b1b;
  background: #fef2f2;
}

.reason-filter-chip.active span {
  color: #991b1b;
}

.view-head .subtle {
  margin: 10px 0 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.bad {
  color: var(--bad);
  background: var(--bad-bg);
}

.disabled {
  color: var(--disabled);
  background: var(--disabled-bg);
}

.unknown {
  color: var(--unknown);
  background: var(--unknown-bg);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--unknown);
}

.status-dot.large {
  width: 14px;
  height: 14px;
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.warn {
  background: var(--warn);
}

.status-dot.bad {
  background: var(--bad);
}

.status-dot.disabled {
  background: var(--disabled);
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.overview-strip > .metric-card {
  padding: 12px 14px;
  border-right: 0;
}

.overview-strip > .metric-card:last-child {
  border-right: 0;
}

.metric-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.metric-action {
  appearance: none;
  font: inherit;
  background: #f0fdfa;
  border-color: #99f6e4;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(15, 118, 110, 0.08);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.metric-readonly {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

.metric-action:hover {
  background: #ccfbf1;
  border-color: #5eead4;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.12);
  transform: translateY(-1px);
}

.metric-action:hover .metric-value,
.metric-action:focus-visible .metric-value {
  color: var(--accent-strong);
}

.metric-action:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.24);
  outline-offset: 4px;
}

.metric-value {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.metric-label {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.issue-line {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.cron-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  overflow: visible;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.cron-tab {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.cron-tab-label {
  display: inline-block;
  min-width: 0;
}

.cron-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.cron-tab:hover {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

.cron-tab.active {
  color: var(--accent-strong);
  background: #f0fdfa;
  border-color: #99f6e4;
}

.cron-tab.active .cron-tab-count {
  background: #ccfbf1;
  color: var(--accent-strong);
}

.summary-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  min-height: 76px;
  padding: 14px 16px;
  background: #fff;
  border-color: var(--line);
  text-align: left;
}

.cron-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 16px;
  border-color: var(--line);
  background: var(--panel);
  cursor: default;
}

.cron-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.cron-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cron-parent {
  width: fit-content;
  margin: 0;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.summary-row:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.summary-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.summary-title {
  font-size: 18px;
  font-weight: 900;
}

.summary-sub {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.summary-metrics {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.summary-metrics strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.secondary {
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  border-color: var(--line);
  font-weight: 750;
}

.secondary:hover {
  border-color: var(--accent);
}

.secondary:disabled,
.login-form input:disabled {
  opacity: 0.68;
}

.secondary:disabled {
  cursor: default;
}

.secondary.is-loading,
.metric-action.is-loading {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  cursor: wait;
}

.secondary.is-loading::before,
.metric-action.is-loading::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.login-form input:disabled {
  cursor: wait;
}

.secondary.active {
  color: var(--accent);
  background: var(--panel-2);
  border-color: var(--accent);
}

.inline-action {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 850;
  cursor: pointer;
}

.inline-action:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pending-action {
  cursor: default;
}

.pending-action:hover {
  border-color: var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(21, 25, 28, 0.42);
}

.modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1080px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(21, 25, 28, 0.22);
}

.modal-wide {
  width: min(1440px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.modal-body {
  display: grid;
  gap: 18px;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.modal-foot[hidden] {
  display: none;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 40;
  width: min(720px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  transform: translateX(-50%);
}

.toast[hidden] {
  display: none;
}

.toast.warn {
  border-color: #facc15;
  background: var(--warn-bg);
  color: var(--warn);
}

.toast.bad {
  border-color: #fda29b;
  background: var(--bad-bg);
  color: var(--bad);
}

.toast.ok {
  border-color: #75e0a7;
  background: var(--ok-bg);
  color: var(--ok);
}

.tiktok-order-list {
  display: grid;
  gap: 10px;
}

.tiktok-order-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tiktok-order-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.tiktok-order-card header > div,
.tiktok-order-grid > div,
.tiktok-product-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.tiktok-order-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(5, minmax(130px, 1fr));
  gap: 12px;
  align-items: start;
}

.tiktok-order-grid span,
.tiktok-order-grid strong,
.tiktok-product-cell span {
  overflow-wrap: anywhere;
}

.tiktok-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.08);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

.config-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.config-form input,
.config-form select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.config-form input:disabled,
.config-form select:disabled {
  color: var(--muted);
  background: var(--panel-2);
}

.config-table {
  min-width: 920px;
}

.config-table td:nth-child(3) {
  width: 110px;
}

.compact-check {
  display: inline-flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--text) !important;
  white-space: nowrap;
}

.compact-check input {
  width: auto;
  min-height: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.dxm-merge-panel,
.dxm-bulk-merge-panel,
.merge-group {
  display: grid;
  gap: 14px;
}

.dxm-bulk-merge-switcher {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: end;
}

.dxm-bulk-merge-switcher label {
  display: grid;
  gap: 6px;
  min-width: min(420px, 100%);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dxm-bulk-merge-switcher select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.dxm-bulk-merge-meta {
  display: grid;
  gap: 4px;
  min-width: 240px;
  text-align: right;
}

.merge-group {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.merge-group:last-child {
  border-bottom: 0;
}

.merge-group-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.merge-table {
  min-width: 1180px;
}

.merge-table td:nth-child(5) {
  min-width: 220px;
  max-width: 360px;
}

.merge-status-orders {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.merge-status-orders li {
  margin: 2px 0;
}

.merge-status-logs {
  margin: 6px 0 0 0;
  padding: 0 0 0 18px;
  list-style: disc;
  max-height: 220px;
  overflow-y: auto;
}

.merge-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.merge-status-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.merge-status-body {
  display: grid;
  gap: 8px;
}

.dxm-buyer-counts {
  display: grid;
  gap: 2px;
}

.dxm-buyer-counts .subtle {
  font-size: 12px;
}

.dxm-buyer-accounts {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.dxm-buyer-accounts b {
  color: var(--text);
  font-weight: 600;
}

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

.dxm-merge-actions .last-merge-success {
  color: var(--ok);
}

.dxm-merge-actions .last-merge-failed {
  color: var(--bad);
}

.dxm-duplicate-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.dxm-bulk-merge-check {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.dxm-bulk-merge-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.dxm-bulk-merge-check input:disabled {
  cursor: not-allowed;
}

.dxm-bulk-merge-check span {
  max-width: 220px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
}

.config-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.config-toggle input[type="checkbox"] {
  margin-top: 4px;
}

.config-toggle span {
  flex: 1;
  font-size: 13px;
  color: var(--muted, #555);
  line-height: 1.4;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.detail-grid {
  display: grid;
  gap: 22px;
}

.detail-tabs-shell {
  display: grid;
  gap: 18px;
}

.detail-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.detail-tab {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.detail-tab:hover {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

.detail-tab.active {
  color: var(--accent-strong);
  background: #f0fdfa;
  border-color: #99f6e4;
}

.detail-tab-panel {
  min-width: 0;
}

.section {
  display: grid;
  gap: 10px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf0f0;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: #f8fafc;
}

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

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #f8fbfa;
}

.empty {
  padding: 16px 0;
}

.live-core {
  display: grid;
  gap: 12px;
}

.live-core-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px 0;
}

.live-core-summary > div {
  min-width: 120px;
}

.live-table-wrap {
  border-color: #cfd8d7;
}

.live-table {
  min-width: 1040px;
}

.live-table th {
  background: #f3f6f5;
}

.live-row.ongoing {
  background: #fbfffd;
}

.live-row.ended {
  background: #fff;
}

.live-row.ongoing:hover {
  background: #f0faf5;
}

.live-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.live-status.ongoing {
  color: #067647;
  background: #dcfae6;
  border-color: #abefc6;
}

.live-status.ended {
  color: #475467;
  background: #f2f4f7;
  border-color: #d0d5dd;
}

.live-info-cell,
.live-time-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.live-info-cell strong {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.live-info-cell span,
.live-time-cell span:nth-child(2) {
  color: var(--muted);
  font-size: 12px;
}

.dxm-duplicate-table {
  min-width: 880px;
}

.dxm-buyer-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dxm-buyer-cell strong,
.dxm-buyer-cell span {
  overflow-wrap: anywhere;
}

.dxm-buyer-cell span {
  color: var(--muted);
  font-size: 12px;
}

.dxm-logistics-cell {
  display: grid;
  gap: 3px;
  max-width: 180px;
  overflow-wrap: anywhere;
}

.package-urgent-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.package-urgent-reasons span {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  color: #991b1b;
  background: #fef2f2;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.list-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.list-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dxm-order-work-wrap {
  border: 1px solid var(--line);
}

.dxm-order-work-table {
  min-width: 1500px;
}

.dxm-order-work-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.dxm-package-table {
  table-layout: fixed;
}

.package-deadline {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.3;
}

.package-deadline.overdue strong,
.package-deadline.overdue span:last-child {
  color: var(--danger, #d63031);
}

.dxm-package-col-equal {
  width: 14%;
}

.dxm-package-col-recipient {
  width: 26%;
}

.dxm-package-col-total {
  width: 9%;
}

.dxm-package-col-shipped {
  width: 8%;
}

.dxm-package-col-event {
  width: 21%;
}

.dxm-package-recipients > div {
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}

.dxm-package-recipients > div + div {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(15, 23, 42, 0.08);
}

.dxm-package-recipients > div > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.package-event-headline {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

.package-scope-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 8px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.08);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.dxm-product-cell,
.dxm-order-id-cell,
.dxm-time-cell,
.dxm-status-cell,
.package-event-cell {
  display: grid;
  gap: 3px;
  overflow-wrap: anywhere;
}

.dxm-product-cell {
  min-width: 220px;
  max-width: 360px;
}

.dxm-order-id-cell {
  min-width: 160px;
}

.dxm-time-cell {
  min-width: 150px;
  color: #334155;
  font-size: 12px;
}

.package-time-cell {
  display: grid;
  gap: 3px;
  min-width: 88px;
  overflow-wrap: anywhere;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    background: var(--bg);
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .workspace {
    height: auto;
    overflow: visible;
    padding: 20px 16px 36px;
  }

  .auth-page .login-panel {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 34px;
    padding: 42px 22px;
  }

  .auth-page .login-panel h2 {
    font-size: 42px;
  }

  .auth-page .login-form {
    width: min(420px, 100%);
  }

  .tiktok-order-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .nav-list,
  .overview-strip {
    grid-template-columns: 1fr;
  }

  .view-head,
  .dxm-bulk-merge-switcher,
  .summary-row {
    display: grid;
  }

  .dxm-bulk-merge-meta {
    text-align: left;
  }

  .summary-metrics {
    justify-content: space-between;
  }

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

  h2 {
    font-size: 28px;
  }

  .auth-page .login-panel h2 {
    font-size: 36px;
  }

  .auth-page .login-panel .subtle {
    font-size: 14px;
  }
}

/* Replay collect button states */
.replay-button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.replay-button:disabled { cursor: not-allowed; opacity: 0.6; }
.replay-button.replay-idle { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.replay-button.replay-idle:hover:not(:disabled) { background: #1d4ed8; }
.replay-button.replay-running { background: #fef3c7; color: #92400e; border-color: #f59e0b; animation: replayPulse 1.6s ease-in-out infinite; }
.replay-button.replay-done { background: #d1fae5; color: #065f46; border-color: #10b981; }
.replay-button.replay-partial { background: #ffedd5; color: #9a3412; border-color: #f97316; }
.replay-button.replay-failed { background: #fee2e2; color: #991b1b; border-color: #ef4444; }
.replay-button.replay-ongoing { background: #e5e7eb; color: #6b7280; border-color: #d1d5db; }
@keyframes replayPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }

/* Replay detail modal */
.replay-detail .replay-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.replay-detail .replay-meta > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #f9fafb;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.replay-phase-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13px;
}
.replay-phase-table th,
.replay-phase-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
.replay-phase-table th { background: #f3f4f6; font-weight: 600; }
.replay-phase-table td.phase-error { color: #b91c1c; font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; }
.phase-pending { color: #6b7280; }
.phase-done { color: #047857; font-weight: 600; }
.phase-running { color: #b45309; font-weight: 600; }
.phase-failed { color: #b91c1c; font-weight: 600; }
.overall-done { color: #047857; font-weight: 600; }
.overall-running { color: #b45309; font-weight: 600; }
.overall-failed { color: #b91c1c; font-weight: 600; }
.overall-partial { color: #c2410c; font-weight: 600; }
.replay-actions { margin-bottom: 12px; }
.replay-log-block { margin-top: 12px; }
.replay-log-header {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
  word-break: break-all;
}
.replay-log-tail {
  background: #111827;
  color: #d1d5db;
  padding: 12px;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Core lives table client-side pagination toolbar */
.live-core-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  font-size: 12px;
  color: #6b7280;
}
.live-core-page-actions { display: flex; gap: 8px; }

/* Replay phase view sub-pages */
.replay-view-button { font-size: 12px; padding: 4px 10px; }
.replay-phase-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}
.replay-phase-title { font-weight: 600; color: #111827; }
.replay-public-warn {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ef4444;
  font-weight: 600;
  margin: 12px 0;
}
.replay-audio-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.replay-audio-meta > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #f9fafb;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.replay-audio-path {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  word-break: break-all;
}
.replay-audio-player {
  width: 100%;
  margin: 12px 0;
}
.replay-sub-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  font-size: 12px;
  color: #6b7280;
  flex-wrap: wrap;
}
.replay-sub-toolbar > div { display: flex; gap: 8px; }
.replay-search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
}
.replay-sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.replay-sub-table th,
.replay-sub-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
.replay-sub-table th { background: #f3f4f6; font-weight: 600; position: sticky; top: 0; }
.replay-sub-table td code { font-size: 11px; }
.replay-stt-preview { color: #4b5563; max-width: 480px; word-break: break-word; }
.replay-stt-full-text {
  width: 100%;
  min-height: 360px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}
.nested-modal-backdrop { z-index: 60; }
