@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f4f6fa;
  --bg-elevated: #ffffff;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --sidebar: #0b1220;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(52, 131, 250, 0.18);
  --ml-yellow: #ffe600;
  --ml-blue: #3483fa;
  --ml-blue-soft: #e8f1ff;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --teal: #0d9488;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --green: #059669;
  --green-soft: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px 0;
  color: #e2e8f0;
  background: linear-gradient(165deg, #0b1220 0%, #111b2e 45%, #0d1525 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 10px;
  flex-shrink: 0;
}

.brand-copy {
  flex: 1;
  min-width: 0;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #64748b;
  background: transparent;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
}

.sidebar-collapse-btn:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-collapse-btn.is-collapsed svg {
  transform: rotate(180deg);
}

@media (min-width: 1081px) {
  .app-shell.sidebar-collapsed {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-shell.sidebar-collapsed .brand {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px 4px 10px;
  }

  .app-shell.sidebar-collapsed .brand-copy,
  .app-shell.sidebar-collapsed .nav-item span:last-child,
  .app-shell.sidebar-collapsed .nav-group-label,
  .app-shell.sidebar-collapsed .nav-group-toggle,
  .app-shell.sidebar-collapsed .account-trigger-copy,
  .app-shell.sidebar-collapsed .account-chevron,
  .app-shell.sidebar-collapsed .account-trigger-dot,
  .app-shell.sidebar-collapsed .user-panel-copy,
  .app-shell.sidebar-collapsed .user-settings-btn,
  .app-shell.sidebar-collapsed .user-logout-btn span {
    display: none;
  }

  .app-shell.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0;
  }

  .app-shell.sidebar-collapsed .account-footer {
    padding-top: 0;
    border-top: 0;
  }

  .app-shell.sidebar-collapsed .account-trigger {
    grid-template-columns: 32px;
    justify-content: center;
    padding: 8px 4px;
  }

  .app-shell.sidebar-collapsed .account-popover {
    left: calc(100% + 8px);
    right: auto;
    bottom: 0;
    width: 220px;
  }

  .app-shell.sidebar-collapsed .user-panel {
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 12px;
    gap: 6px;
  }

  .app-shell.sidebar-collapsed .user-panel-main {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
  }

  .app-shell.sidebar-collapsed .user-panel-actions {
    flex-direction: column;
    width: 100%;
    align-items: center;
  }

  .app-shell.sidebar-collapsed .user-logout-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }

  .app-shell.sidebar-collapsed .user-panel-icon {
    display: block;
  }
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  margin-right: -2px;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding-bottom: 14px;
  display: grid;
  gap: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ml-yellow) 0%, #f5c800 100%);
  color: #0b1220;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(255, 230, 0, 0.25);
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
}

.nav-group-label {
  padding: 14px 10px 6px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-section {
  display: grid;
  gap: 2px;
}

.nav-group-collapsible {
  margin-top: 4px;
}

.nav-group-collapsible[hidden] {
  display: none !important;
}

.nav-group-toggle {
  padding: 14px 10px 6px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color var(--transition);
}

.nav-group-toggle::-webkit-details-marker {
  display: none;
}

.nav-group-toggle::after {
  content: "▸";
  font-size: 11px;
  color: #475569;
  transition: transform 0.15s ease, color 0.15s ease;
}

.nav-group-collapsible[open] > .nav-group-toggle::after {
  transform: rotate(90deg);
  color: #94a3b8;
}

.nav-group-toggle:hover {
  color: #94a3b8;
}

.nav-group-collapsible .nav-section {
  padding-bottom: 4px;
}

.nav-item {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: #94a3b8;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

/* display:flex 会盖掉原生 [hidden]，必须显式覆盖 */
.nav-item[hidden],
.nav-group-collapsible[hidden] {
  display: none !important;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item:hover {
  color: #f1f5f9;
  background: var(--sidebar-hover);
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-active);
  box-shadow: inset 3px 0 0 var(--ml-blue);
}

.nav-item.active svg {
  opacity: 1;
  color: var(--ml-blue);
}

.sidebar-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 12px;
}

.panel-label {
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.account-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: #64748b;
  flex-shrink: 0;
}

.status-dot.ok {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.status-dot.pending {
  background: var(--ml-yellow);
  box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.15);
}

.account-row strong {
  display: block;
  font-size: 13px;
}

.account-row span {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.4;
}

.account-panel {
  gap: 10px;
}

/* ── Compact account footer ── */
.account-footer {
  position: relative;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.account-trigger {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: #e2e8f0;
  background: transparent;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  transition: background var(--transition);
}

.account-trigger:hover,
.account-trigger.open {
  background: rgba(255, 255, 255, 0.06);
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ml-yellow) 0%, #f5c800 100%);
  color: #0b1220;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.account-trigger-copy {
  min-width: 0;
}

.account-trigger-copy strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-trigger-copy span {
  display: block;
  color: #94a3b8;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-trigger-dot {
  margin-top: 0;
}

.account-chevron {
  width: 14px;
  height: 14px;
  color: #64748b;
  transition: transform var(--transition);
}

.account-trigger.open .account-chevron {
  transform: rotate(180deg);
  color: #94a3b8;
}

.account-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: #151f33;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 8px;
  z-index: 20;
}

.account-popover[hidden] {
  display: none !important;
}

.account-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.account-popover-close {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  color: #94a3b8;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.account-popover-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.account-popover-current {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-popover-current span {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 700;
}

.account-popover-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.account-popover-list {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
}

.account-popover-item {
  width: 100%;
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  font: inherit;
  font-size: 11px;
  text-align: left;
  transition: background var(--transition), border-color var(--transition);
}

.account-popover-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.account-popover-item.active {
  background: rgba(255, 230, 0, 0.12);
  border: 1px solid rgba(255, 230, 0, 0.28);
}

.account-popover-item-name {
  font-weight: 700;
}

.account-popover-item-meta {
  color: #94a3b8;
  font-size: 10px;
  white-space: nowrap;
}

.account-popover-hint {
  margin: 0;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.55;
}

.orders-sync-settings {
  display: none;
}

.account-action {
  flex: 1;
  min-width: 0;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.account-action.primary {
  color: #0b1220;
  background: var(--ml-yellow);
}

.account-action.primary.reauthorize,
.account-action#reauthorizeBtn {
  color: #fff;
  background: #d97706;
}

.account-action.ghost {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  flex: 0 0 auto;
  min-width: 52px;
}

.account-current {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 8px;
}

.account-current-copy strong {
  display: block;
  font-size: 13px;
  color: #f8fafc;
}

.account-current-copy span {
  display: block;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.4;
}

.account-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-meta span {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 700;
}

.account-select-label {
  display: grid;
  gap: 6px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.account-select {
  width: 100%;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.55);
  font-size: 12px;
  font-weight: 600;
}

.account-panel-actions {
  display: grid;
  gap: 8px;
}

.primary-button.full,
.ghost-button.full {
  width: 100%;
}

.sidebar-panel .primary-button.reauthorize {
  color: #fff;
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.sidebar-panel .primary-button:not(.reauthorize) {
  color: #0b1220;
  background: linear-gradient(135deg, var(--ml-yellow) 0%, #f5c800 100%);
  box-shadow: none;
}

.sidebar-panel .ghost-button {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.topbar-account-wrap {
  position: relative;
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: inherit;
  font: inherit;
  cursor: default;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.topbar-account.switchable {
  cursor: pointer;
}

.topbar-account.switchable:hover,
.topbar-account.switchable.open {
  border-color: rgba(52, 131, 250, 0.35);
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.topbar-account-chevron {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.topbar-account.open .topbar-account-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.topbar-account-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  max-width: min(320px, 80vw);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
  z-index: 30;
}

.topbar-account-popover[hidden] {
  display: none !important;
}

.topbar-account-popover-label {
  margin: 0;
  padding: 4px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-account-popover-list {
  display: grid;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.topbar-account-popover-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: inherit;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.topbar-account-popover-item:hover {
  background: var(--bg-elevated);
}

.topbar-account-popover-item.active {
  border-color: rgba(52, 131, 250, 0.35);
  background: rgba(52, 131, 250, 0.08);
}

.topbar-account-popover-item-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.topbar-account-popover-item-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.topbar-account-popover-item-badge {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.topbar-account-copy strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.topbar-account-copy span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.sidebar-accounts {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.sidebar-account-item {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 2px;
  text-align: left;
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-account-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-account-item.active {
  border-color: rgba(52, 131, 250, 0.45);
  background: rgba(52, 131, 250, 0.14);
  color: #f8fafc;
}

.sidebar-account-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-account-meta {
  font-size: 10px;
  color: #94a3b8;
}

.sidebar-account-item.active .sidebar-account-meta {
  color: #bfdbfe;
}

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

.account-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.account-card.active {
  border-color: #93c5fd;
  background: linear-gradient(90deg, #eff6ff 0%, #fff 100%);
}

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

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

.account-card-title strong {
  font-size: 14px;
}

.account-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.account-empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.status-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}

/* ── Workspace ── */
.workspace {
  padding: 0;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 20px 28px;
  background: rgba(244, 246, 250, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-title-wrap h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-title-wrap p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-box {
  width: min(250px, 30vw);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box:focus-within {
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.12);
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-box input {
  width: 100%;
  height: auto;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  font-size: 13px;
}

.market-select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg-elevated);
}

.workspace-body {
  padding: 16px clamp(12px, 1.6vw, 22px) 18px;
}

/* ── Buttons ── */
.primary-button,
.ghost-button,
.danger-button,
.text-button,
.icon-button {
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--ml-blue) 0%, var(--brand) 100%);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.ghost-button {
  color: var(--ink-secondary);
  background: var(--bg-elevated);
  border-color: var(--line);
}

.ghost-button:hover {
  background: var(--line-soft);
}

.ghost-button.compact {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.ghost-button.danger {
  color: #b91c1c;
  background: #fff7f7;
  border-color: #fecaca;
}

.ghost-button.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.ghost-button.full {
  width: 100%;
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.danger-button:not(:disabled):hover {
  background: #b91c1c;
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.text-button {
  color: var(--ml-blue);
  background: transparent;
  font-weight: 600;
}

.icon-button {
  width: 38px;
  padding: 0;
  background: var(--bg-elevated);
  border-color: var(--line);
  display: grid;
  place-items: center;
}

/* ── Notice & Metrics ── */
.notice-band {
  min-height: 52px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.notice-band strong {
  font-size: 13px;
}

.notice-band span {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  position: relative;
  min-height: 108px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 2px;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}

.metric-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ml-blue);
}

.metric-card.danger::before { background: var(--danger); }
.metric-card.warn::before,
.metric-card.amber::before { background: var(--warn); }

.metric-card > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.metric-card strong {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metric-card small {
  color: var(--muted);
  font-size: 11px;
}

/* ── Views & Grid ── */
.view {
  display: none;
  animation: fadeIn 280ms ease;
}

.view.active {
  display: block;
}

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

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.surface {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
  align-items: center;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ── Chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.success { color: var(--green); background: var(--green-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.danger { color: var(--danger); background: var(--danger-soft); }
.chip.neutral { color: #475569; background: #f1f5f9; }
.chip.info { color: var(--brand); background: var(--ml-blue-soft); }

/* ── List items ── */
.alert-list,
.catalog-list,
.task-stack,
.automation-list {
  display: grid;
  gap: 8px;
}

.alert-item,
.catalog-item,
.task-item,
.automation-item {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition);
}

.alert-item:hover,
.catalog-item:hover {
  border-color: #cbd5e1;
}

.alert-item.urgent {
  border-color: #fecaca;
  background: linear-gradient(90deg, #fff5f5 0%, #fff 100%);
}

.item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 50%, #fce7f3 100%);
  flex-shrink: 0;
}

.item-copy {
  min-width: 0;
  flex: 1;
}

.item-copy strong,
.item-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-copy strong {
  font-size: 13px;
}

.item-copy span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.badge {
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ── Charts ── */
.bar-chart {
  height: 140px;
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 16px 4px 4px;
}

.bar-chart span {
  flex: 1;
  min-width: 14px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--ml-blue) 0%, #60a5fa 100%);
  opacity: 0.85;
  transition: opacity var(--transition);
}

.bar-chart span:hover {
  opacity: 1;
}

.chart-caption,
.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.chart-caption strong,
.donut-wrap strong {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.chart-caption span,
.donut-wrap span,
small {
  color: var(--muted);
  font-size: 12px;
}

.donut-wrap {
  justify-content: center;
  gap: 20px;
  height: 140px;
}

.donut {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 62%, var(--warn) 62% 77%, #e2e8f0 77% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: #fff;
}

.split-stats {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* ── API Listing Stepper ── */
.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 10px;
  padding: 0;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.step {
  position: relative;
  min-height: 64px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 10px 10px 10px 12px;
  color: #94a3b8;
  background: #f8fafc;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.step:last-child {
  border-right: 0;
}

.step::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
}

.step-badge {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #94a3b8;
  background: #fff;
  border: 2px solid #cbd5e1;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  transition: all var(--transition);
}

.step-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.step-name {
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.step-meta {
  color: inherit;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
  line-height: 1.2;
}

.step.pending {
  color: #94a3b8;
  background: #f8fafc;
}

.step.pending .step-name {
  color: #64748b;
}

.step.pending .step-meta {
  color: #94a3b8;
}

.step.pending .step-badge {
  color: #94a3b8;
  background: #fff;
  border-color: #cbd5e1;
  border-style: dashed;
}

.step.active {
  color: var(--ml-blue);
  background: linear-gradient(180deg, #eff6ff 0%, #fff 100%);
  box-shadow: inset 0 0 0 1px rgba(52, 131, 250, 0.12);
  z-index: 1;
}

.step.active::after {
  background: var(--ml-blue);
}

.step.active .step-name {
  color: var(--ink);
}

.step.active .step-meta {
  color: var(--ml-blue);
  font-weight: 700;
}

.step.active .step-badge {
  color: #fff;
  background: var(--ml-blue);
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.18);
}

.step.done {
  color: #047857;
  background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf4 100%);
}

.step.done::after {
  background: var(--green);
}

.step.done .step-name {
  color: #065f46;
}

.step.done .step-meta {
  color: #059669;
  font-weight: 700;
}

.step.done .step-badge {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  font-size: 13px;
  line-height: 1;
}

.stepper-hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.publish-progress {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff 0%, var(--line-soft) 100%);
}

.publish-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.publish-progress-head strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.publish-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.publish-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #3483fa 0%, #16a34a 100%);
  transition: width 0.35s ease;
}

.publish-progress.is-failed {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff 0%, #fef2f2 100%);
}

.publish-progress-bar.is-failed {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.publish-progress-sites {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.publish-progress-sites li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line-soft);
  font-size: 12px;
}

.publish-progress-sites a {
  color: var(--ml-blue);
  text-decoration: none;
}

.publish-progress-sites a:hover {
  text-decoration: underline;
}

.publish-status-cell {
  min-width: 140px;
}

.publish-status-cell .publish-progress-track {
  height: 6px;
  margin-top: 6px;
}

.publish-status-cell .publish-progress-bar {
  background: linear-gradient(90deg, #3483fa 0%, #22c55e 100%);
}

.publish-status-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

/* ── Forms ── */
.listing-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.listing-form-core {
  grid-column: span 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 10px;
  row-gap: 4px;
  align-items: start;
}

#listing.view {
  position: relative;
}

.listing-workspace {
  align-items: start;
  gap: 12px;
}

#listing .listing-workbench {
  padding: 14px 16px 12px;
}

#listing .listing-workbench-heading {
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

#listing .listing-workbench-heading p {
  margin-top: 2px;
}

.listing-workbench-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

#listing .listing-stepper-compact {
  margin-bottom: 8px;
}

#listing .listing-stepper-compact .step {
  min-height: 42px;
  padding: 6px 8px;
  gap: 8px;
}

#listing .listing-stepper-compact .step-badge {
  width: 22px;
  height: 22px;
  font-size: 10px;
  border-width: 1.5px;
}

#listing .listing-stepper-compact .step.active .step-badge {
  box-shadow: 0 0 0 2px rgba(52, 131, 250, 0.16);
}

#listing .listing-stepper-compact .step-name {
  font-size: 11px;
}

#listing .listing-stepper-compact .step-meta {
  font-size: 9px;
}

.listing-block {
  grid-column: span 2;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px 10px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.listing-block::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #cbd5e1;
}

.listing-common-block {
  background: linear-gradient(180deg, #f3f8ff 0%, #f8fbff 55%, #fff 100%);
  border-color: #d7e6fb;
}

.listing-common-block::before {
  background: var(--ml-blue);
}

.listing-variations-block {
  background: linear-gradient(180deg, #f4f7fb 0%, #f8fafc 50%, #fff 100%);
  border-color: #d8dee8;
}

.listing-variations-block::before {
  background: #64748b;
}

.listing-block + .listing-block,
.listing-block + .listing-advanced {
  margin-top: 8px;
}

.listing-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 28px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
}

.listing-block-title {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.listing-common-block .listing-block-title {
  color: #1e3a8a;
}

.listing-variations-block .listing-block-title {
  color: #334155;
}

.listing-block-title-hint {
  margin-left: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.listing-block-desc {
  display: none;
}

.listing-variations-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.listing-add-variation-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  min-width: 0;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--ml-blue);
  border-radius: 999px;
  background: var(--ml-blue);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.listing-add-variation-btn:hover {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.listing-add-variation-icon {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.listing-variations-list {
  display: grid;
  gap: 6px;
}

.listing-variation-card {
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.listing-variation-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
}

.listing-variation-card-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.listing-variation-remove {
  padding: 2px 6px;
  font-size: 11px;
}

.listing-variation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 8px;
  row-gap: 4px;
  align-items: start;
}

.listing-variation-grid .listing-image-field,
.listing-variation-grid .listing-field-span-2 {
  grid-column: 1 / -1;
}

#listing .listing-form label,
#listing .listing-field {
  gap: 2px;
}

#listing .listing-form-toolbar {
  margin-bottom: 0;
  padding: 0 2px;
  min-height: 0;
}

#listing .listing-form-toolbar .form-section-title {
  display: none;
}

#listing .current-draft-context {
  padding: 2px 0 0;
  gap: 6px;
}

#listing .current-draft-label {
  min-height: 22px;
  padding: 0 8px;
  font-size: 11px;
}

#listing .current-draft-meta {
  font-size: 11px;
}

#listing .listing-field .field-head,
#listing .listing-image-field > .field-head {
  margin-bottom: 1px;
  font-size: 11px;
  line-height: 1.2;
}

#listing .listing-form input:not([type="file"]),
#listing .listing-form select,
#listing .listing-form textarea,
#listing .listing-image-row input[data-var-field="picture"],
#listing .listing-image-row input[name="picture"] {
  min-height: 32px;
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

#listing .listing-form textarea {
  height: auto;
  min-height: 64px;
  padding: 8px 10px;
}

#listing .listing-image-upload-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

#listing .listing-image-upload-btn svg {
  width: 15px;
  height: 15px;
}

#listing .listing-image-field {
  gap: 2px;
}

#listing .listing-image-preview {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  flex-shrink: 0;
}

#listing .listing-image-preview img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

#listing .listing-image-status {
  font-size: 11px;
  line-height: 1.3;
  min-height: 0;
}

#listing .listing-advanced {
  margin-top: 0;
}

#listing .listing-advanced > summary {
  padding: 8px 10px;
  font-size: 12px;
}

#listing .listing-sticky-actions {
  position: sticky;
  bottom: 8px;
  z-index: 8;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
}

#listing .listing-sticky-actions .action-row {
  margin-top: 0;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#listing .listing-draft-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  padding-left: 4px;
  color: var(--ink-secondary);
  white-space: nowrap;
}

#listing .listing-draft-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

#listing .listing-draft-meta .panel-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

#listing .listing-draft-meta strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

#listing .listing-sticky-actions .primary-button,
#listing .listing-sticky-actions .ghost-button,
#listing .listing-sticky-actions .danger-button {
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

#listing .validation-panel,
#listing .extra-attributes-panel {
  margin-top: 10px;
  padding: 10px;
}

@media (max-width: 900px) {
  .listing-variation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  #listing .listing-draft-meta {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    padding-top: 2px;
  }
}

.listing-preview-drawer {
  position: fixed;
  top: 42%;
  right: 0;
  z-index: 35;
  display: flex;
  align-items: flex-start;
  max-height: calc(100vh - 120px);
  pointer-events: none;
  transform: translateY(-20%);
}

.listing-preview-tab {
  --note: #fff7d6;
  --note-edge: #f0df9a;
  --note-ink: #7a6418;
  pointer-events: auto;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  position: relative;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 28px;
  min-height: 96px;
  margin: 0;
  padding: 18px 4px 14px;
  border: 1px solid var(--note-edge);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0%, transparent 38%),
    var(--note);
  box-shadow: -2px 3px 10px rgba(120, 96, 20, 0.12);
  color: var(--note-ink);
  cursor: pointer;
  transition: width 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.listing-preview-tab::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, transparent 48%, rgba(0, 0, 0, 0.06) 50%, rgba(255, 255, 255, 0.55) 52%);
  border-bottom-left-radius: 2px;
  pointer-events: none;
}

.listing-preview-tab-pin {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #f4a4a4 45%, #d96b6b 100%);
  box-shadow: 0 1px 2px rgba(120, 40, 40, 0.25);
  transform: translateX(-50%);
}

.listing-preview-tab:hover {
  width: 32px;
  box-shadow: -3px 4px 14px rgba(120, 96, 20, 0.18);
}

.listing-preview-drawer.is-open .listing-preview-tab {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.45) 0%, transparent 38%),
    #ffe9a8;
  border-color: #e6c86a;
}

.listing-preview-tab-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1;
}

.listing-preview-tab-status,
.listing-preview-tab .chip {
  writing-mode: horizontal-tb;
  transform: none;
  margin: 0;
  padding: 2px 5px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--note-ink);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  max-width: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-preview-tab-status.success,
.listing-preview-tab .chip.success {
  background: rgba(220, 252, 231, 0.95);
  color: #166534;
}

.listing-preview-tab-status.info,
.listing-preview-tab .chip.info {
  background: rgba(219, 234, 254, 0.95);
  color: #1d4ed8;
}

.listing-preview-tab-status.warn,
.listing-preview-tab .chip.warn {
  background: rgba(254, 243, 199, 0.95);
  color: #92400e;
}

.listing-preview-tab-status.danger,
.listing-preview-tab .chip.danger {
  background: rgba(254, 226, 226, 0.95);
  color: #b91c1c;
}

.listing-preview-panel {
  pointer-events: auto;
  width: min(360px, calc(100vw - 36px));
  max-height: min(72vh, 640px);
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--note-edge, #f0df9a);
  border-right: 0;
  border-radius: 14px 0 0 14px;
  background: #fffdf5;
  box-shadow: -10px 8px 28px rgba(90, 70, 20, 0.14);
}

.listing-preview-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.listing-preview-panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.listing-preview-panel-title-row h2 {
  margin: 0;
}

.listing-preview-panel-status,
.listing-preview-panel-status.chip {
  margin: 0;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.3;
}

.listing-preview-panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.listing-preview-panel .draft-preview-card {
  margin-bottom: 12px;
}

.listing-variation-preview-list {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.listing-variation-preview-item {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  color: var(--ink-secondary);
}

#listing.view .listing-workspace {
  padding-right: 20px;
}

@media (max-width: 720px) {
  .listing-preview-drawer {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: none;
    flex-direction: column-reverse;
    transform: none;
  }

  .listing-preview-tab {
    writing-mode: horizontal-tb;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px 12px 0 0;
    border-right: 1px solid var(--note-edge);
    justify-content: center;
    gap: 8px;
  }

  .listing-preview-tab-pin {
    position: static;
    transform: none;
  }

  .listing-preview-tab::before {
    display: none;
  }

  .listing-preview-panel {
    width: 100%;
    max-height: min(70vh, 520px);
    border-radius: 16px 16px 0 0;
    border-right: 1px solid var(--note-edge);
  }

  .listing-variation-grid {
    grid-template-columns: 1fr;
  }

  #listing.view .listing-workspace {
    padding-right: 0;
  }
}

.listing-field {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.listing-field-span-2 {
  grid-column: span 2;
}

.listing-field .field-head,
.listing-image-field > .field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 8px;
  width: 100%;
  margin-bottom: 2px;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.field-head-main {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.field-counter {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.field-counter.ok {
  color: #15803d;
}

.field-counter.warn {
  color: #d97706;
}

.field-counter.error {
  color: #dc2626;
}

.listing-field-row-spacer {
  display: none;
}

.listing-form.is-readonly {
  opacity: 0.96;
}

.listing-form.is-readonly .listing-form-toolbar,
.listing-form.is-readonly #newListingDraftBtn,
.listing-form.is-readonly #cloneCurrentDraftBtn,
.listing-form.is-readonly #clearListingDraftBtn {
  opacity: 1;
}

#listing .listing-workbench-heading-actions .ghost-button.compact {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.listing-category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 2px;
}

.listing-category-row > input,
.listing-category-row .listing-category-ref-wrap input {
  width: 100%;
  min-width: 0;
}

.listing-category-ref-wrap {
  position: relative;
  min-width: 0;
}

.listing-category-ref-wrap.has-image input {
  color: var(--muted);
}

.listing-category-ref-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  border: none;
  background: #eff6ff;
  color: #2563eb;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease;
}

.listing-category-ref-badge:hover {
  background: #dbeafe;
}

.listing-field-status {
  display: block;
  min-height: 0;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-secondary);
}

.listing-field-status:not(:empty) {
  min-height: 16px;
}

.listing-field-status.pending {
  color: var(--ink-secondary);
}

.listing-field-status.ok {
  color: #15803d;
}

.listing-field-status.warn {
  color: #b45309;
  font-weight: 600;
}

.listing-field-status.error {
  color: var(--danger);
  font-weight: 600;
}

.listing-mini-btn {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.listing-mini-btn:hover:not(:disabled) {
  border-color: var(--ml-blue);
  color: var(--ml-blue);
  background: var(--ml-blue-soft);
}

.listing-mini-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.listing-image-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
}

.listing-image-field.field-error > .field-head {
  color: var(--danger);
}

.listing-image-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.listing-image-upload-btn {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--line-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform 0.12s ease;
}

.listing-image-upload-btn:hover {
  border-color: var(--ml-blue);
  color: var(--ml-blue);
  background: var(--ml-blue-soft);
}

.listing-image-upload-btn:active {
  transform: scale(0.96);
}

.listing-image-upload-btn svg {
  width: 18px;
  height: 18px;
}

.listing-image-row input[name="picture"],
.listing-image-row #listingPictureUrl,
.listing-image-row input[data-var-field="picture"] {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  line-height: 1.4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.listing-image-upload-btn input[type="file"] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.listing-image-row input[name="picture"]:focus,
.listing-image-row #listingPictureUrl:focus {
  outline: none;
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.1);
}

.listing-image-field.field-error input[name="picture"],
.listing-image-field.field-error #listingPictureUrl {
  border-color: #fecaca;
  background: #fffafa;
}

.listing-image-status:empty {
  display: none;
}

.listing-image-preview[hidden] {
  display: none !important;
}

.listing-image-preview {
  display: flex;
  align-items: center;
  margin-top: 0;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.listing-image-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.listing-image-status.is-loading {
  color: var(--ml-blue);
}

.listing-image-status.is-success {
  color: var(--green);
}

.listing-image-status.is-error {
  color: var(--danger);
}

.listing-form label {
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  gap: 6px;
}

.listing-form .wide {
  grid-column: span 2;
}

.listing-form .field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.listing-form label.required-field {
  color: var(--ink-secondary);
}

.listing-form label.required-field::before {
  content: "关键";
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--ink-secondary);
  background: #eef2f7;
  font-size: 10px;
  font-weight: 900;
}

.listing-form label.field-error,
.listing-field.field-error .field-head {
  color: var(--danger);
}

.listing-form label.field-error::before {
  content: "必填";
  color: var(--danger);
  background: var(--danger-soft);
}

.listing-form label.field-error .field-hint {
  color: var(--danger);
}

.listing-form input:not([type="file"]),
.listing-form select,
.listing-form textarea {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.listing-form label.field-error input,
.listing-form label.field-error select,
.listing-form label.field-error textarea {
  border-color: #fecaca;
  background: #fffafa;
}

.listing-form input:focus,
.listing-form select:focus,
.listing-form textarea:focus {
  outline: none;
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px rgba(52, 131, 250, 0.1);
}

.listing-form label.field-error input:focus,
.listing-form label.field-error select:focus,
.listing-form label.field-error textarea:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

.listing-form textarea {
  height: 72px;
  padding: 10px 12px;
  resize: vertical;
}

.form-section-title {
  grid-column: span 2;
  margin-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.listing-form-toolbar {
  grid-column: span 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.listing-form-toolbar-main {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.listing-form-toolbar .form-section-title {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.listing-form-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 2px;
}

.listing-form-toolbar .ghost-button.compact {
  flex-shrink: 0;
  margin-top: 0;
}

.current-draft-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.current-draft-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
}

.current-draft-context.is-new .current-draft-label {
  background: #f1f5f9;
  color: var(--ink-secondary);
}

.current-draft-context.is-dirty .current-draft-label {
  background: #fff7ed;
  color: #c2410c;
}

.current-draft-meta {
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.listing-advanced {
  grid-column: span 2;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  overflow: hidden;
}

.listing-advanced > summary {
  padding: 12px 14px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.listing-advanced > summary::-webkit-details-marker {
  display: none;
}

.listing-advanced > summary::after {
  content: "展开";
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.listing-advanced[open] > summary::after {
  content: "收起";
}

.listing-advanced > summary:hover {
  background: var(--line-soft);
}

.listing-advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line-soft);
}

.listing-advanced-grid .wide {
  grid-column: span 2;
}

.listing-advanced-grid .form-section-title {
  margin-top: 8px;
}

.unit-input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  align-items: center;
}

.unit-input-group .unit-select {
  width: 72px;
  min-width: 72px;
  padding-left: 10px;
  padding-right: 24px;
  text-align: left;
  font-weight: 700;
  color: var(--ink-secondary);
  background-color: #f8fafc;
  cursor: pointer;
}

.listing-form label.field-error .unit-input-group .unit-select {
  background: #fffafa;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ── Validation panel ── */
.validation-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--line-soft);
}

.validation-panel.pass {
  border-color: #86efac;
  background: var(--green-soft);
}

.validation-panel.fail {
  border-color: #fca5a5;
  background: var(--danger-soft);
}

.validation-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
}

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

.validation-list li {
  font-size: 12px;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.validation-list li::before {
  content: "·";
  color: var(--muted);
}

.validation-list li.error {
  color: var(--danger);
  font-weight: 600;
}

.validation-list li.ok {
  color: var(--green);
}

/* ── Payload preview ── */
.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.draft-preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  padding: 16px;
}

.draft-preview-card.is-empty {
  min-height: 180px;
}

.draft-preview-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px 24px;
}

.draft-preview-card.is-empty .draft-preview-empty {
  min-height: 140px;
}

.draft-preview-empty p {
  margin: 0;
  max-width: 280px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.draft-preview-summary {
  margin: 0;
  display: grid;
  gap: 10px;
}

.draft-preview-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fff;
}

.draft-preview-item dt {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.draft-preview-item dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

.draft-preview-technical {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.draft-preview-technical > summary {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.draft-preview-technical > summary::-webkit-details-marker {
  display: none;
}

.draft-preview-technical > summary:hover {
  background: var(--line-soft);
  color: var(--ink-secondary);
}

.draft-preview-technical[open] > summary {
  border-bottom: 1px solid var(--line-soft);
}

.draft-preview-technical .payload-preview {
  border: 0;
  border-radius: 0;
}

.payload-preview {
  height: 380px;
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  color: #a5b4fc;
  background: #0f172a;
  overflow: auto;
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  border: 1px solid #1e293b;
}

.payload-preview.compact-preview {
  height: 200px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── API Setup flow ── */
.api-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.flow-step {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 6px;
  transition: border-color var(--transition);
}

.flow-step.active {
  border-color: #93c5fd;
  background: var(--ml-blue-soft);
}

.flow-step span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  color: #fff;
  background: var(--ml-blue);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.flow-step small,
.route-grid span,
.config-card dt {
  color: var(--muted);
  font-size: 11px;
}

.config-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--line-soft);
}

.config-card dl {
  margin: 0;
  display: grid;
  gap: 12px;
}

.config-card div {
  display: grid;
  gap: 3px;
}

.config-card dd {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.45;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.route-grid div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  display: grid;
  align-content: center;
  gap: 4px;
  transition: border-color var(--transition);
}

.route-grid div:hover {
  border-color: #93c5fd;
}

.route-grid strong {
  font-size: 12px;
  font-weight: 700;
  word-break: break-word;
  color: var(--brand);
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

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

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--line-soft);
}

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

tr:hover td {
  background: #fafbfc;
}

.batch-upc-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.batch-category-cell {
  max-width: 220px;
  line-height: 1.45;
  word-break: break-word;
}

.batch-store-chip {
  display: inline-flex;
  align-items: center;
  max-width: 140px;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.batch-store-chip--blue {
  color: #1d4ed8;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #bfdbfe;
}

.batch-store-chip--violet {
  color: #6d28d9;
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  border-color: #ddd6fe;
}

.batch-store-chip--teal {
  color: #0f766e;
  background: linear-gradient(180deg, #f0fdfa 0%, #ccfbf1 100%);
  border-color: #99f6e4;
}

.batch-store-chip--amber {
  color: #b45309;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
}

.batch-store-chip--rose {
  color: #be123c;
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: #fecdd3;
}

.batch-store-chip--emerald {
  color: #047857;
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
}

.batch-store-chip--orange {
  color: #c2410c;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fed7aa;
}

.batch-store-chip--indigo {
  color: #3730a3;
  background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: #c7d2fe;
}

.batch-store-chip--cyan {
  color: #0e7490;
  background: linear-gradient(180deg, #ecfeff 0%, #cffafe 100%);
  border-color: #a5f3fc;
}

.batch-store-chip--slate {
  color: #475569;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  border-color: #cbd5e1;
}

/* ── Matrix / Inventory / Campaign ── */
.matrix-grid,
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.matrix-cell,
.stock-card,
.campaign-card {
  min-height: 100px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  display: grid;
  align-content: center;
  gap: 4px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.matrix-cell:hover,
.campaign-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.matrix-cell strong,
.stock-card strong,
.campaign-card strong {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.matrix-cell span,
.stock-card span,
.campaign-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.matrix-cell.hot,
.stock-card.critical {
  border-color: #fecaca;
  background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
}

.campaign-card small {
  color: var(--green);
  font-weight: 700;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.98);
  transition: transform 200ms ease;
}

.modal-backdrop.show .modal {
  transform: translateY(0) scale(1);
}

.user-settings-modal {
  width: min(620px, 100%);
  max-height: min(84vh, 880px);
  overflow: auto;
  padding: 22px 24px 24px;
}

.user-settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eef2f6;
}

.user-settings-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.user-settings-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

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

.session-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.session-row.is-current {
  border-color: #93c5fd;
  background: #eff6ff;
}

.session-row-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.session-row-main strong {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: #0f172a;
}

.session-type {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  background: #e2e8f0;
}

.session-row-main span {
  color: #64748b;
  font-size: 12px;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.session-badge.is-current {
  color: #1d4ed8;
  background: #dbeafe;
}

.session-badge.is-legacy {
  color: #92400e;
  background: #fef3c7;
}

.session-row.is-legacy {
  opacity: 0.92;
}

.sessions-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.sessions-legacy-note {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12.5px;
  line-height: 1.45;
}

.session-row-actions {
  flex: 0 0 auto;
}

.auth-otp-hint {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

.ghost-button.full {
  width: 100%;
  margin-top: 8px;
}

.user-settings-section {
  border: 1px solid #e8edf3;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.user-settings-section + .user-settings-section {
  margin-top: 12px;
}

.user-settings-section-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.user-settings-section-head h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.user-settings-section-head p {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.user-settings-empty {
  margin: 0;
  padding: 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.user-settings-alert {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.45;
}

.user-settings-alert[hidden],
.user-settings-empty[hidden],
.orders-sync-settings-body[hidden] {
  display: none;
}

.orders-sync-settings-body {
  padding: 14px 16px 16px;
  background: #fcfdff;
}

.user-settings-options {
  display: grid;
  gap: 8px;
}

.user-settings-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid #e8edf3;
  border-radius: 12px;
  background: #f8fafc;
}

.user-settings-option-copy {
  min-width: 0;
}

.user-settings-option-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.user-settings-option-copy span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.user-settings-option.is-inactive {
  opacity: 0.72;
}

.user-settings-option.is-inactive .mp-switch {
  pointer-events: none;
  opacity: 0.55;
}

.mp-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}

.mp-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.mp-switch-track {
  display: block;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 160ms ease;
  position: relative;
}

.mp-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
  transition: transform 160ms ease;
}

.mp-switch input:checked + .mp-switch-track {
  background: linear-gradient(135deg, var(--ml-blue) 0%, var(--brand) 100%);
}

.mp-switch input:checked + .mp-switch-track::after {
  transform: translateX(18px);
}

.mp-switch input:focus-visible + .mp-switch-track {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 2px;
}

.mp-switch-warn input:checked + .mp-switch-track {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.user-settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #e8edf3;
  border-radius: 12px;
  background: #fff;
}

.user-settings-field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.user-settings-select {
  min-width: 128px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid #d7dee8;
  background: #fff;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.user-settings-select:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 1px;
  border-color: #93c5fd;
}

.user-settings-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.user-settings-status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.user-settings-status.is-loading .user-settings-status-dot {
  background: #3b82f6;
  animation: user-settings-pulse 1.2s ease-in-out infinite;
}

.user-settings-status.is-live .user-settings-status-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

@keyframes user-settings-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.45;
    transform: scale(0.82);
  }
}

.user-settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eef2f6;
}

@media (max-width: 760px) {
  .user-settings-modal {
    width: min(96vw, 100%);
    max-height: 88vh;
    padding: 16px;
  }

  .user-settings-field {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-settings-select {
    width: 100%;
  }
}

.user-settings-actions-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-settings-actions .primary-button.compact,
.user-settings-actions .ghost-button.compact {
  height: 34px;
  padding: 0 14px;
  font-size: 12.5px;
}

.orders-sync-settings-body .orders-sync-status-line {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.modal-image-preview {
  width: min(640px, 100%);
  padding: 16px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.modal-image-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-image-preview-head h3 {
  margin: 0;
}

.modal-image-preview img {
  display: block;
  width: 100%;
  max-height: min(70vh, 520px);
  object-fit: contain;
  border-radius: 8px;
  background: #f8fafc;
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.modal-summary {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.modal label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.modal input:not([type="checkbox"]):not([type="radio"]) {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.draft-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.draft-summary div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #f8fafc;
  display: grid;
  gap: 5px;
}

.draft-summary strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-summary .wide-result {
  grid-column: span 3;
}

.text-button.small {
  height: auto;
  padding: 0;
  font-size: 12px;
}

.danger-text {
  color: var(--danger);
}

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

.extra-attributes-panel {
  margin-top: 14px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 14px;
  background: #fffafa;
}

.extra-attributes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--sidebar);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Auth gate ── */
.auth-boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(52, 131, 250, 0.12), transparent 42%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.auth-boot-card {
  display: grid;
  gap: 16px;
  justify-items: center;
  padding: 28px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.auth-boot-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-boot-brand span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.auth-gate {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 24px 56px;
  background:
    radial-gradient(circle at top right, rgba(52, 131, 250, 0.12), transparent 42%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.site-beian-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  text-align: center;
  pointer-events: none;
}

.site-beian-footer a {
  pointer-events: auto;
  color: #94a3b8;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.site-beian-footer a:hover {
  color: #64748b;
  background: #fff;
  border-color: #cbd5e1;
  text-decoration: none;
}

.auth-gate[hidden],
.app-shell[hidden],
.auth-boot[hidden] {
  display: none !important;
}

html.mp-session-hint #authBoot,
html.mp-session-hint #authGate {
  display: none !important;
}

html.mp-session-hint #appShell {
  display: grid !important;
}

.app-shell.auth-validating {
  pointer-events: none;
}

.app-shell.auth-validating .workspace {
  opacity: 0.92;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--line-soft);
}

.auth-tab {
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 700;
}

.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form[hidden] {
  display: none !important;
}

.auth-tabs[hidden],
.auth-tab[hidden] {
  display: none !important;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.auth-form input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}

.auth-closed {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  color: #c2410c;
  font-size: 13px;
  line-height: 1.6;
}

.auth-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.auth-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  font-size: 13px;
  color: #dc2626;
  line-height: 1.5;
}

.primary-button.full {
  width: 100%;
}

.user-panel {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-panel-main {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.user-panel-main:hover .user-panel-copy strong {
  color: #fff;
}

.user-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.user-settings-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(226, 232, 240, 0.88);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.user-settings-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.user-panel-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.user-panel-icon {
  display: none;
  width: 18px;
  height: 18px;
  opacity: 0.82;
}

.user-panel-copy strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel-copy span {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(226, 232, 240, 0.88);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}

.user-logout-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.user-logout-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── Chat float widget ── */
.chat-widget {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}

.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1202;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--ml-blue) 0%, var(--brand) 100%);
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.38);
  font-size: 14px;
  font-weight: 700;
  transition: transform var(--transition), box-shadow var(--transition);
}

.chat-fab.is-dragging {
  cursor: grabbing;
  transform: none;
}

.chat-widget > .chat-fab {
  pointer-events: auto;
}

.chat-drawer[hidden] {
  display: none !important;
}

.chat-drawer {
  position: fixed;
  z-index: 1201;
  width: 640px;
  height: min(86vh, 860px);
  min-width: 360px;
  min-height: 420px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  border: 1px solid #e5eaf0;
  border-radius: 18px;
  background: #fcfdfe;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.7) inset,
    0 24px 64px rgba(15, 23, 42, 0.16);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  pointer-events: auto;
  animation: chat-drawer-in 0.22s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

.chat-drawer.is-dragging,
.chat-drawer.is-resizing {
  user-select: none;
  transition: none;
}

.chat-drawer-resize-handles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.chat-drawer-resize {
  position: absolute;
  pointer-events: auto;
}

.chat-drawer-resize-n,
.chat-drawer-resize-s {
  left: 10px;
  right: 10px;
  height: 8px;
}

.chat-drawer-resize-n {
  top: 0;
  cursor: ns-resize;
}

.chat-drawer-resize-s {
  bottom: 0;
  cursor: ns-resize;
}

.chat-drawer-resize-e,
.chat-drawer-resize-w {
  top: 10px;
  bottom: 10px;
  width: 8px;
}

.chat-drawer-resize-e {
  right: 0;
  cursor: ew-resize;
}

.chat-drawer-resize-w {
  left: 0;
  cursor: ew-resize;
}

.chat-drawer-resize-ne,
.chat-drawer-resize-nw,
.chat-drawer-resize-se,
.chat-drawer-resize-sw {
  width: 14px;
  height: 14px;
}

.chat-drawer-resize-ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.chat-drawer-resize-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.chat-drawer-resize-se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}

.chat-drawer-resize-sw {
  left: 0;
  bottom: 0;
  cursor: nesw-resize;
}

.chat-fab:hover:not(.is-dragging) {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.45);
}

.chat-fab-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.chat-fab-close {
  display: none;
}

.chat-fab[aria-expanded="true"] .chat-fab-open {
  display: none;
}

.chat-fab[aria-expanded="true"] .chat-fab-close {
  display: block;
}

.chat-fab[aria-expanded="true"] {
  width: 52px;
  padding: 0;
  justify-content: center;
}

.chat-fab[aria-expanded="true"] .chat-fab-label {
  display: none;
}

.chat-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 12px;
  border-bottom: 1px solid #e8edf3;
  background: linear-gradient(180deg, #f7f9fc 0%, #fcfdfe 100%);
  cursor: grab;
  touch-action: none;
}

.chat-drawer-head:active {
  cursor: grabbing;
}

.chat-drawer-drag {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.chat-drawer-drag svg {
  width: 16px;
  height: 16px;
  color: #94a3b8;
  flex-shrink: 0;
}

.chat-drawer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-drawer-action {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
  line-height: 1;
}

.chat-drawer-action:hover,
.chat-drawer-action.active {
  color: var(--ink);
  background: var(--line-soft);
}

@keyframes chat-drawer-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-drawer-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-drawer-title strong {
  font-size: 15px;
  font-weight: 650;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.chat-drawer-title span {
  font-size: 12px;
  color: #7b8da0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-drawer-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.chat-drawer-close:hover {
  color: var(--ink);
  background: var(--line-soft);
}

.chat-drawer-body {
  min-height: 0;
  overflow: hidden;
}

.chat-drawer-body .chat-layout {
  grid-template-columns: 176px minmax(0, 1fr);
  min-height: 100%;
  height: 100%;
}

.chat-drawer-body .chat-layout.sessions-collapsed {
  grid-template-columns: 44px minmax(0, 1fr);
}

.chat-drawer-body .chat-layout.sessions-collapsed .chat-session-sidebar {
  display: grid;
}

.chat-drawer-body .chat-layout.sessions-collapsed .chat-session-toolbar-title,
.chat-drawer-body .chat-layout.sessions-collapsed .chat-session-new-btn,
.chat-drawer-body .chat-layout.sessions-collapsed .chat-session-list {
  display: none;
}

.chat-drawer-body .chat-layout.sessions-collapsed .chat-session-toolbar {
  justify-content: center;
  padding: 12px 6px;
  border-bottom: 0;
}

.chat-drawer-body .chat-session-sidebar {
  max-height: none;
  border-right: 1px solid #e8edf3;
  border-bottom: 0;
  background: #f5f7fa;
}

.chat-drawer-body .chat-main {
  padding: 10px 14px 14px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  background: #fafbfd;
}

.chat-skills-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
}

.chat-skills-hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  line-height: 1.4;
}

.chat-skills-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(240px, 40vh);
  overflow-y: auto;
}

.chat-skill-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
  cursor: pointer;
}

.chat-skill-toggle input {
  margin-top: 3px;
}

.chat-skill-toggle-main {
  min-width: 0;
  flex: 1;
}

.chat-skill-toggle-name {
  font-size: 13px;
  font-weight: 600;
}

.chat-skill-toggle-desc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  line-height: 1.35;
}

.chat-drawer-body .chat-log {
  min-height: 0;
  max-height: none;
  height: 100%;
}

.chat-stream-cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--ml-blue);
  animation: chat-cursor-blink 1s step-end infinite;
}

.chat-stream-status {
  color: var(--muted);
  font-size: 0.92em;
}

@keyframes chat-cursor-blink {
  50% {
    opacity: 0;
  }
}

body.chat-dragging {
  cursor: grabbing;
  user-select: none;
}

/* ── Chat assistant ── */
.chat-panel {
  padding: 0;
  overflow: hidden;
}

.chat-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: calc(100vh - 180px);
}

.chat-session-sidebar {
  border-right: 1px solid #e8edf3;
  background: linear-gradient(180deg, #f5f7fa 0%, #fafbfd 100%);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100%;
}

.chat-session-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 10px;
  border-bottom: 1px solid #e8edf3;
}

.chat-session-toolbar-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.02em;
}

.chat-session-collapse-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #64748b;
  background: transparent;
  transition: color var(--transition), background var(--transition), transform var(--transition);
}

.chat-session-collapse-btn svg {
  width: 16px;
  height: 16px;
}

.chat-session-collapse-btn:hover {
  color: #334155;
  background: rgba(15, 23, 42, 0.06);
}

.chat-session-collapse-btn.is-collapsed svg {
  transform: rotate(180deg);
}

.chat-session-new-btn {
  flex-shrink: 0;
  font-size: 12px;
}

.chat-session-list {
  overflow-y: auto;
  padding: 8px 6px;
  display: grid;
  gap: 4px;
  align-content: start;
}

.chat-session-empty {
  padding: 16px 10px;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.6;
}

.chat-session-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: start;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background var(--transition), border-color var(--transition);
}

.chat-session-item:hover {
  background: rgba(255, 255, 255, 0.72);
}

.chat-session-item.active {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.chat-session-select {
  display: grid;
  gap: 2px;
  padding: 9px 8px;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.chat-session-select strong {
  font-size: 13px;
  font-weight: 550;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-session-select span,
.chat-session-select small {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-session-delete {
  width: 28px;
  height: 28px;
  margin: 6px 4px 0 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
  line-height: 1;
}

.chat-session-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

.chat-main {
  display: grid;
  gap: 14px;
  padding: 18px;
  grid-template-rows: 1fr auto auto;
  min-width: 0;
}

.chat-model-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.chat-model-field {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.chat-model-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.chat-model-field select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: #fff;
  font-size: 13px;
}

.chat-model-bar .chip {
  margin-left: auto;
}

.chat-main .section-heading {
  padding: 0;
}

.chat-log {
  min-height: 360px;
  max-height: min(58vh, 640px);
  overflow-y: auto;
  border: 1px solid #e8edf3;
  border-radius: 14px;
  padding: 14px;
  background: #f3f5f8;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-empty {
  margin: auto;
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
  line-height: 1.65;
}

.chat-bubble {
  max-width: min(760px, 92%);
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.72;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}

.chat-bubble.user .chat-bubble-text {
  white-space: pre-wrap;
}

.chat-msg-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 9px;
  margin: 1px 2px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
  text-decoration: none;
  vertical-align: baseline;
  word-break: break-word;
  transition: background 140ms ease, border-color 140ms ease;
}

.chat-bubble.user .chat-msg-link {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.chat-bubble.user .chat-msg-link:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.55);
}

.chat-bubble.assistant .chat-msg-link,
.chat-md .chat-msg-link {
  color: #1d4ed8;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
}

.chat-bubble.assistant .chat-msg-link:hover,
.chat-md .chat-msg-link:hover {
  background: #bfdbfe;
  border-color: #93c5fd;
}

.chat-bubble.assistant {
  align-self: flex-start;
  color: #1e293b;
  background: #fff;
  border: 1px solid #e8edf3;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.chat-bubble.assistant .chat-bubble-text {
  white-space: normal;
}

.chat-thinking {
  margin-bottom: 10px;
  border: 1px solid #e8edf3;
  border-radius: 12px;
  background: #f8fafc;
  overflow: hidden;
}

.chat-thinking > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}

.chat-thinking > summary::-webkit-details-marker {
  display: none;
}

.chat-thinking > summary::before {
  content: "▸ ";
}

.chat-thinking[open] > summary::before {
  content: "▾ ";
}

.chat-thinking-body {
  padding: 0 12px 10px;
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  border-top: 1px solid #edf2f7;
}

.chat-agent-work {
  margin-bottom: 10px;
  border: 1px solid #e8edf3;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafbfc 0%, #f4f7fb 100%);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chat-agent-work > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-agent-work > summary:hover {
  background: rgba(255, 255, 255, 0.65);
  color: #475569;
}

.chat-agent-work-cache {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 11px;
  font-weight: 700;
}

.chat-agent-work > summary::-webkit-details-marker {
  display: none;
}

.chat-agent-work > summary::before {
  content: "▸ ";
}

.chat-agent-work[open] > summary::before {
  content: "▾ ";
}

.chat-agent-work-body {
  padding: 8px 12px 12px;
  border-top: 1px solid #e8edf3;
  display: grid;
  gap: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.chat-work-record {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-work-record--thought {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #edf2f7;
}

.chat-work-record--thought .chat-work-record-text {
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.65;
}

.chat-work-record--tool {
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #edf2f7;
}

.chat-work-record--ok {
  border-color: #d1fae5;
  background: #f8fffb;
}

.chat-work-record--fail {
  border-color: #fecaca;
  background: #fff8f8;
}

.chat-work-record--active {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.chat-work-record-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
}

.chat-work-record--ok .chat-work-record-icon {
  color: #047857;
  background: #d1fae5;
}

.chat-work-record--fail .chat-work-record-icon {
  color: #b91c1c;
  background: #fee2e2;
}

.chat-work-record--active .chat-work-record-icon {
  color: #1d4ed8;
  background: #dbeafe;
}

.chat-work-record-main {
  min-width: 0;
  flex: 1;
}

.chat-work-record-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-work-record-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.chat-work-record-status {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.chat-work-record-status--ok {
  color: #047857;
  background: #ecfdf5;
}

.chat-work-record-status--fail {
  color: #b91c1c;
  background: #fef2f2;
}

.chat-work-record-status--active {
  color: #1d4ed8;
  background: #eff6ff;
}

.chat-work-record-meta,
.chat-work-record-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-work-record-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 2px;
}

.chat-agent-work--answer-phase {
  margin-bottom: 8px;
  border-color: #e8edf3;
  background: linear-gradient(180deg, #fafbfc 0%, #f6f8fb 100%);
}

.chat-agent-work--answer-phase > summary {
  padding: 8px 10px;
  font-weight: 600;
}

.chat-work-step {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.55;
}

.chat-work-step-icon {
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.chat-work-step--active .chat-work-step-icon {
  color: var(--ml-blue);
}

.chat-work-step--done .chat-work-step-icon {
  color: #16a34a;
}

.chat-work-step--error .chat-work-step-icon {
  color: var(--danger);
}

.chat-work-step-main {
  min-width: 0;
  flex: 1;
}

.chat-work-step-label {
  color: var(--ink-secondary);
  font-weight: 600;
}

.chat-work-step-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  word-break: break-word;
}

.chat-work-step-meta--cache {
  color: #047857;
  font-weight: 700;
}

.chat-work-step-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-work-step-detail--pending,
.chat-work-step-detail--muted {
  color: var(--muted);
  font-style: italic;
}

.chat-work-step-thinking {
  margin-top: 4px;
  border: 1px solid #e8edf3;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.chat-work-step-thinking > summary {
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}

.chat-work-step-thinking > summary::-webkit-details-marker {
  display: none;
}

.chat-work-step-thinking[open] > summary {
  border-bottom: 1px solid #edf2f7;
}

.chat-work-step-running {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.chat-work-step--tool.chat-work-step--active .chat-work-step-label,
.chat-work-step--skill.chat-work-step--active .chat-work-step-label {
  color: #1d4ed8;
}

.chat-agent-work-summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-agent-work-minimal {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chat-agent-work-pulse {
  animation: chat-agent-work-pulse 1.6s ease-in-out infinite;
}

@keyframes chat-agent-work-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.chat-work-step-compact {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  padding: 2px 0;
  word-break: break-word;
}

.chat-work-step-compact--active {
  color: #1d4ed8;
}

.chat-work-step-compact--muted {
  font-style: italic;
}

.chat-agent-live-body {
  display: grid;
  gap: 10px;
}

.chat-agent-live-text {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

.chat-agent-live-action {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
}

.chat-agent-live-action-icon {
  flex: 0 0 auto;
  width: 16px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

.chat-agent-live-action--active {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #f8fbff;
}

.chat-agent-live-action--active .chat-agent-live-action-icon {
  color: #1d4ed8;
}

.chat-final-answer {
  margin-top: 2px;
}

.chat-work-step--active .chat-work-step-label {
  color: var(--ink);
}

.chat-bubble.error {
  align-self: flex-start;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #fecaca;
}

.chat-bubble.loading {
  align-self: flex-start;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
}

.chat-composer {
  margin-top: 0;
}

.chat-composer-stack {
  display: grid;
  gap: 8px;
}

.chat-composer-footer {
  display: grid;
  gap: 6px;
}

.chat-composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-tool-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: min(180px, 42vw);
  height: 30px;
  padding: 0 8px 0 6px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chat-tool-select-wrap:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.chat-tool-select-wrap:has(select:disabled) {
  opacity: 0.55;
}

.chat-tool-select-wrap--image-setting {
  max-width: min(156px, 36vw);
}

.chat-tool-select-wrap--image-setting .chat-tool-select {
  min-width: 52px;
}

.chat-tool-select-label {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #94a3b8;
  text-transform: uppercase;
}

.chat-tool-select {
  min-width: 0;
  flex: 1;
  height: 28px;
  border: 0;
  padding: 0 14px 0 0;
  background: transparent;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  text-overflow: ellipsis;
}

.chat-tool-select:focus {
  outline: none;
}

.chat-tool-select:disabled {
  cursor: not-allowed;
}

.chat-tools-popover-wrap {
  position: relative;
}

.chat-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  color: #475569;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chat-tool-btn:hover,
.chat-tool-btn.open {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.chat-skills-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #1d4ed8;
  background: #dbeafe;
}

.chat-tools-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: min(320px, 78vw);
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.chat-tools-popover[hidden] {
  display: none !important;
}

.chat-status-mini {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

.chat-status-mini.is-ready {
  color: #15803d;
}

.chat-status-mini.is-warn {
  color: #b45309;
}

.chat-status-mini.is-pending {
  color: #64748b;
}

.chat-status-mini.is-saving {
  color: #1d4ed8;
}

.chat-composer-main {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 6px 8px 6px 6px;
  background: #fff;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-composer-main:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-attach-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #94a3b8;
  background: #f1f5f9;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.chat-attach-btn:hover {
  color: #3b82f6;
  background: #eff6ff;
}

.chat-attach-btn svg {
  width: 18px;
  height: 18px;
}

.chat-composer-main textarea {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 160px;
  border: 0;
  padding: 8px 4px;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.55;
  font-family: inherit;
  color: #1e293b;
}

.chat-composer-main textarea::placeholder {
  color: #a8b4c4;
}

.chat-composer-main textarea:focus {
  outline: none;
  box-shadow: none;
}

.chat-send-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.chat-send-btn:hover {
  opacity: 0.92;
}

.chat-send-btn:active {
  transform: scale(0.96);
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-send-btn .chat-stop-icon {
  display: none;
}

.chat-send-btn.is-stop {
  background: #ef4444;
}

.chat-send-btn.is-stop .chat-send-icon {
  display: none;
}

.chat-send-btn.is-stop .chat-stop-icon {
  display: block;
}

.chat-composer-hint {
  margin: 0;
  padding: 0 4px;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
}

.chat-md-p {
  margin: 0 0 8px;
}

.chat-md-p:last-child {
  margin-bottom: 0;
}

.chat-md-spacer {
  height: 6px;
}

.chat-md-heading {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.chat-md-heading + .chat-md-p {
  margin-top: 0;
}

.chat-bubble-text.chat-md strong {
  font-size: 1.05em;
  font-weight: 650;
  color: var(--ink);
}

.chat-bubble.user .chat-bubble-text strong {
  color: #fff;
}

.chat-md-code {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
}

.chat-bubble.user .chat-md-code {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.chat-md-pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.55;
}

.chat-md-pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre;
}

.chat-md-ul,
.chat-md-ol {
  margin: 6px 0 10px;
  padding-left: 1.4em;
}

.chat-md-ul {
  list-style: disc;
}

.chat-md-ol {
  list-style: decimal;
}

.chat-md-ul li,
.chat-md-ol li {
  margin: 4px 0;
  padding-left: 2px;
}

.chat-md-ul li::marker,
.chat-md-ol li::marker {
  color: var(--ml-blue);
}

.chat-md-hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 10px 0;
}

.chat-md-table-wrap {
  overflow-x: auto;
  margin: 8px 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.chat-md-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 280px;
  font-size: 12px;
}

.chat-md-table th,
.chat-md-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}

.chat-md-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  background: #f8fafc;
  white-space: nowrap;
}

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

.chat-md-table td .chat-md-code {
  font-size: 11px;
}

.chat-bubble-text.chat-md em {
  font-style: italic;
  color: inherit;
}

.chat-attachment-preview {
  position: relative;
  width: fit-content;
  max-width: 180px;
}

.chat-attachment-preview img {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.chat-attachment-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, 0.75);
  font-size: 14px;
  line-height: 1;
}

.chat-bubble-image {
  display: block;
  max-width: 220px;
  max-height: 160px;
  border-radius: 8px;
  margin-bottom: 8px;
  object-fit: cover;
}

.chat-generated-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-generated-image {
  margin: 0;
  max-width: 220px;
}

.chat-generated-image--clickable {
  cursor: zoom-in;
}

.chat-generated-image--clickable:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
  border-radius: 8px;
}

.chat-generated-image img {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 8px;
}

.chat-generated-image img.is-broken {
  min-height: 80px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px dashed rgba(248, 113, 113, 0.35);
}

.chat-generated-image figcaption {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted, #64748b);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.chat-image-lightbox[hidden] {
  display: none !important;
}

.chat-image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(2px);
}

.chat-image-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 1200px);
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel, #fff);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.chat-image-lightbox.is-compare .chat-image-lightbox-panel {
  width: min(98vw, 1480px);
  max-width: min(98vw, 1480px);
}

.chat-image-lightbox-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.chat-image-lightbox-compare[hidden] {
  display: none !important;
}

.chat-image-lightbox-col {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.chat-image-lightbox-col figcaption {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-align: center;
}

.chat-image-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 140px);
  object-fit: contain;
  border-radius: 8px;
  margin: 0 auto;
  background: #f1f5f9;
}

.chat-image-lightbox-img.is-single {
  width: 100%;
  height: calc(92vh - 140px);
  max-height: calc(92vh - 140px);
  object-fit: contain;
}

.chat-image-lightbox-img[hidden] {
  display: none !important;
}

.chat-image-lightbox-compare .chat-image-lightbox-img {
  max-height: calc(92vh - 160px);
  width: 100%;
}

@media (max-width: 900px) {
  .chat-image-lightbox-compare {
    grid-template-columns: 1fr;
  }
}

.chat-image-lightbox-caption {
  font-size: 13px;
  color: var(--muted, #64748b);
  line-height: 1.4;
  word-break: break-word;
}

.chat-image-lightbox-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.chat-image-lightbox-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text, #0f172a);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

body.chat-image-lightbox-open {
  overflow: hidden;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .brand div:not(.brand-mark),
  .nav-item span:last-child,
  .nav-group-label,
  .account-trigger-copy,
  .account-chevron,
  .account-trigger-dot {
    display: none;
  }

  .account-footer {
    padding-top: 0;
    border-top: 0;
  }

  .account-trigger {
    grid-template-columns: 32px;
    justify-content: center;
    padding: 8px 4px;
  }

  .account-popover {
    left: calc(100% + 8px);
    right: auto;
    bottom: 0;
    width: 220px;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .span-4,
  .span-5,
  .span-7 {
    grid-column: span 12;
  }
}

@media (max-width: 768px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px;
  }

  .brand {
    padding: 0;
    flex-shrink: 0;
  }

  .nav-section {
    display: flex;
    gap: 4px;
  }

  .nav-item {
    width: 40px;
    flex-shrink: 0;
  }

  .topbar,
  .workspace-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions,
  .search-box {
    width: 100%;
  }

  .metric-grid,
  .listing-form,
  .listing-form-core,
  .listing-advanced-grid,
  .matrix-grid,
  .inventory-grid,
  .campaign-grid,
  .stepper {
    grid-template-columns: 1fr;
  }

  .step {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    min-height: 56px;
  }

  .step:last-child {
    border-bottom: 0;
  }

  .api-flow,
  .route-grid,
  .draft-summary,
  .extra-attributes-grid {
    grid-template-columns: 1fr;
  }

  .listing-form .wide,
  .listing-form-core,
  .listing-advanced-grid .wide,
  .listing-advanced,
  .form-section-title {
    grid-column: span 1;
  }

  .notice-band,
  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-session-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 180px;
  }

  .chat-widget {
    right: 16px;
    bottom: 16px;
  }

  .chat-drawer {
    width: calc(100vw - 24px) !important;
    height: min(88vh, 860px) !important;
    left: 12px !important;
    top: 12px !important;
  }
}

/* ── Agent Monitor (admin) ── */

.agent-monitor-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 140px);
}

.agent-monitor-sidebar {
  min-width: 0;
}

.agent-monitor-sidebar,
.agent-monitor-main {
  min-height: 520px;
}

.agent-monitor-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.agent-monitor-toolbar > div:first-child {
  min-width: 0;
}

.agent-monitor-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.agent-monitor-toolbar h2 {
  margin: 0;
  font-size: 1rem;
}

.agent-monitor-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.agent-monitor-connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.agent-monitor-connection.online {
  color: var(--success, #0a7a43);
}

.agent-monitor-keep-limit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.agent-monitor-keep-limit select {
  min-width: 64px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.agent-monitor-detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-monitor-follow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.agent-monitor-run-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  max-height: calc(100vh - 240px);
  overflow: auto;
}

.agent-monitor-run {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-2, #fafafa);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  overflow: visible;
}

.agent-monitor-run.active {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #2563eb) 35%, transparent);
}

.agent-monitor-run-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.agent-monitor-run-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.agent-monitor-run-meta,
.agent-monitor-run-id,
.agent-monitor-run-preview {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.agent-monitor-run-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.agent-monitor-run-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-monitor-run-cache {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #047857;
  font-weight: 700;
}

.agent-monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  flex-shrink: 0;
}

.agent-monitor-badge.compact {
  padding: 3px 8px 3px 6px;
  font-size: 0.68rem;
}

.agent-monitor-badge-text {
  flex: 0 0 auto;
  white-space: nowrap;
}

.agent-monitor-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.65);
}

.agent-monitor-badge.running {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fdba74;
}

.agent-monitor-badge.running .agent-monitor-badge-dot {
  background: #f97316;
  animation: agent-monitor-pulse 1.2s ease-in-out infinite;
}

.agent-monitor-badge.error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.agent-monitor-badge.error .agent-monitor-badge-dot {
  background: #ef4444;
}

.agent-monitor-badge.done {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.agent-monitor-badge.done .agent-monitor-badge-dot {
  background: #10b981;
}

.agent-monitor-badge.cancelled {
  background: #f8fafc;
  color: #475569;
  border-color: #e2e8f0;
}

.agent-monitor-badge.cancelled .agent-monitor-badge-dot {
  background: #94a3b8;
}

.agent-monitor-badge.timeout {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.agent-monitor-badge.timeout .agent-monitor-badge-dot {
  background: #f59e0b;
}

@keyframes agent-monitor-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.88);
  }
}

.agent-monitor-badge-wrap {
  flex-shrink: 0;
  justify-self: end;
}

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

.agent-monitor-detail-head h2 {
  margin: 0;
}

.agent-monitor-detail-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}

.agent-monitor-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.agent-monitor-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2, #fafafa);
}

.agent-monitor-panel.span-2 {
  grid-column: span 2;
}

.agent-monitor-panel h3 {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
}

.agent-monitor-collapsible {
  background: var(--surface-2, #fafafa);
}

.agent-monitor-collapsible > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.agent-monitor-collapsible > summary::-webkit-details-marker {
  display: none;
}

.agent-monitor-panel-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid transparent;
  background: rgba(255, 255, 255, 0.65);
}

.agent-monitor-collapsible[open] > .agent-monitor-panel-summary {
  border-bottom-color: var(--line);
}

.agent-monitor-panel-summary:hover {
  background: rgba(255, 255, 255, 0.92);
}

.agent-monitor-panel-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.agent-monitor-panel-chevron {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.agent-monitor-collapsible[open] > .agent-monitor-panel-summary .agent-monitor-panel-chevron {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.agent-monitor-panel-body .agent-monitor-code,
.agent-monitor-panel-body .agent-monitor-messages,
.agent-monitor-panel-body .agent-monitor-timeline {
  border-top: none;
}

.agent-monitor-panel-body .agent-monitor-timeline {
  padding: 12px;
}

.agent-monitor-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: normal;
}

.agent-monitor-code,
.agent-monitor-event pre {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}

.agent-monitor-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
}

.agent-monitor-message {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: visible;
}

.agent-monitor-message-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
  background: #f3f4f6;
  border-radius: 10px 10px 0 0;
}

.agent-monitor-message.user .agent-monitor-message-head {
  background: #eff6ff;
  color: #1d4ed8;
}

.agent-monitor-message.assistant .agent-monitor-message-head {
  background: #ecfdf5;
  color: #047857;
}

.agent-monitor-message-body {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border-radius: 0 0 10px 10px;
}

.agent-monitor-message.user .agent-monitor-message-body {
  background: #f8fbff;
}

.agent-monitor-message.assistant .agent-monitor-message-body {
  background: #f9fefb;
}

.agent-monitor-message.tool .agent-monitor-message-head {
  background: #fff7ed;
  color: #c2410c;
}

.agent-monitor-message.tool .agent-monitor-message-body {
  background: #fffaf5;
}

.agent-monitor-loop-messages {
  margin-top: 8px;
  padding: 8px 10px 10px;
  border-left: 3px solid #c7d2fe;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
}

.agent-monitor-loop-messages-label {
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.agent-monitor-loop-messages .agent-monitor-messages {
  gap: 8px;
}

.agent-monitor-loop-compare {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px;
}

.agent-monitor-loop-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.agent-monitor-loop-section.compact {
  border-color: #c7d2fe;
  background: #f8fafc;
}

.agent-monitor-loop-section-title {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.agent-monitor-loop-section.compact .agent-monitor-loop-section-title {
  background: #eef2ff;
  color: #3730a3;
}

.agent-monitor-loop-section .agent-monitor-messages {
  padding: 12px;
}

.agent-monitor-loop-legacy-note {
  padding: 8px 12px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.78rem;
}

.agent-monitor-tool-calls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px 0;
}

.agent-monitor-tool-call {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  overflow: hidden;
}

.agent-monitor-tool-call-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #dbeafe;
  font-size: 0.78rem;
}

.agent-monitor-tool-call-head strong {
  color: #1d4ed8;
}

.agent-monitor-tool-call-head code {
  font-size: 0.72rem;
  color: #475569;
  word-break: break-all;
}

.agent-monitor-tool-call-args {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fbff;
}

.agent-monitor-tool-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
}

.agent-monitor-tool-meta strong {
  color: #c2410c;
}

.agent-monitor-tool-meta code {
  color: #475569;
  word-break: break-all;
}

.agent-monitor-inline-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.68rem;
  font-weight: 700;
}

.agent-monitor-state-block {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
  white-space: pre-wrap;
}

.agent-monitor-state-panel {
  background: #f8fffb;
  max-height: 360px;
}

.agent-monitor-empty-inline {
  color: var(--muted);
}

.agent-monitor-panel.span-2 .agent-monitor-messages,
.agent-monitor-panel.span-2 .agent-monitor-code {
  max-height: 420px;
}

.agent-monitor-event-detail {
  padding: 0 12px 12px;
}

.agent-monitor-event-section {
  margin-top: 10px;
}

.agent-monitor-event-section strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.agent-monitor-event-raw {
  margin-top: 10px;
}

.agent-monitor-event-raw summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--muted);
}

.agent-monitor-event-raw pre {
  margin-top: 6px;
  max-height: 240px;
  overflow: auto;
}

.agent-monitor-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  max-height: 520px;
  overflow: auto;
}

.agent-monitor-event {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.agent-monitor-event summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.agent-monitor-event summary::-webkit-details-marker {
  display: none;
}

.agent-monitor-event-time {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 64px;
}

.agent-monitor-event-title {
  font-size: 0.84rem;
  font-weight: 600;
}

.agent-monitor-event.tool summary {
  background: #fff7ed;
}

.agent-monitor-event.result summary {
  background: #f0fdf4;
}

.agent-monitor-event.ui summary {
  background: #eff6ff;
}

.agent-monitor-event.llm summary {
  background: #f5f3ff;
}

.agent-monitor-event.message summary {
  background: #ecfeff;
}

.agent-monitor-event.error summary {
  background: #fef2f2;
}

.agent-monitor-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.agent-monitor-empty.error {
  color: #b91c1c;
}

/* ── Admin Item Lookup ── */

.item-lookup-page {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.item-lookup-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.item-lookup-head h2 {
  margin: 0 0 6px;
}

.item-lookup-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 720px;
}

.item-lookup-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.item-lookup-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2, #fafafa);
}

.item-lookup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.item-lookup-field.wide {
  grid-column: 1 / -1;
}

.item-lookup-field input,
.item-lookup-field select,
.item-lookup-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.item-lookup-field textarea {
  resize: vertical;
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.item-lookup-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.item-lookup-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sales-diag-hint {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.sales-diag-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.sales-diag-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.sales-diag-summary span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.sales-diag-summary strong {
  display: block;
  font-size: 0.9rem;
}

.sales-diag-summary strong.ok {
  color: #047857;
}

.sales-diag-summary strong.error {
  color: #b91c1c;
}

.item-lookup-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.item-lookup-summary-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-width: 0;
}

.item-lookup-summary-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.item-lookup-summary-card strong {
  display: block;
  font-size: 0.86rem;
  word-break: break-word;
}

.item-lookup-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.item-lookup-panel-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  background: rgba(255, 255, 255, 0.7);
}

.item-lookup-panel-summary::-webkit-details-marker {
  display: none;
}

.item-lookup-panel-title {
  font-weight: 600;
}

.item-lookup-panel-body {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #fff;
}

.item-lookup-code {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.72rem;
  line-height: 1.45;
  overflow: auto;
  max-height: 480px;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-lookup-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.item-lookup-badge.ok {
  background: #ecfdf5;
  color: #047857;
}

.item-lookup-badge.error {
  background: #fef2f2;
  color: #b91c1c;
}

.item-lookup-meta {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
}

.item-lookup-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
}

.item-lookup-diagnostics {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.item-lookup-diagnostic {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.5;
}

.item-lookup-diagnostic-ok {
  color: #166534;
  background: rgba(22, 101, 52, 0.08);
  border: 1px solid rgba(22, 101, 52, 0.18);
}

.item-lookup-diagnostic-info {
  color: #1d4ed8;
  background: rgba(29, 78, 216, 0.08);
  border: 1px solid rgba(29, 78, 216, 0.16);
}

.item-lookup-diagnostic-warn {
  color: #b45309;
  background: rgba(180, 83, 9, 0.08);
  border: 1px solid rgba(180, 83, 9, 0.16);
}

.item-lookup-diagnostic-error {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.16);
}

.item-lookup-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.item-lookup-image-card {
  display: block;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.item-lookup-image-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-lookup-insight {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.item-lookup-insight-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-lookup-insight-head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.item-lookup-insight-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 16px;
}

.item-lookup-insight-hero {
  display: block;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.item-lookup-insight-hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-lookup-insight-fields {
  display: grid;
  gap: 10px;
}

.item-lookup-insight-fields div {
  display: grid;
  gap: 4px;
}

.item-lookup-insight-fields span {
  color: var(--muted);
  font-size: 12px;
}

.item-lookup-insight-fields strong {
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.item-lookup-image-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.item-lookup-image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.item-lookup-image-card.selectable {
  position: relative;
  cursor: pointer;
}

.item-lookup-image-card.selectable.is-selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.item-lookup-image-card.selectable.is-main {
  border-color: #16a34a;
}

.item-lookup-image-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 16px;
  height: 16px;
}

.item-lookup-image-flag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
}

.item-lookup-image-open {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  text-align: center;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #1d4ed8;
  font-size: 12px;
  text-decoration: none;
}

.item-lookup-field select,
.item-lookup-field input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
}

.item-lookup-options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  grid-column: 1 / -1;
}

.item-lookup-checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding-top: 0.35rem;
}

.item-lookup-checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
}

.item-lookup-fields-picker {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
}

.item-lookup-fields-picker legend {
  padding: 0 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.item-lookup-fields-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
}

.item-lookup-fields-grid label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
}

.item-lookup-fields-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.sales-backfill-details {
  margin-top: 4px;
}

.sales-backfill-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.sales-backfill-summary::-webkit-details-marker {
  display: none;
}

.sales-backfill-summary::before {
  content: "▸";
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.sales-backfill-details[open] > .sales-backfill-summary::before {
  transform: rotate(90deg);
}

.sales-backfill-summary:hover {
  color: #2563eb;
}

.sales-backfill-details-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.sales-sync-actions {
  margin-bottom: 0;
}

.sales-backfill-note {
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 6px;
}

.sales-backfill-row.is-worker-active {
  background: rgba(37, 99, 235, 0.05);
  border-radius: 8px;
  padding: 8px;
  margin: 0 -8px;
}

.sales-backfill-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sales-backfill-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  border-radius: 999px;
  padding: 1px 6px;
}

.sales-backfill-row + .sales-backfill-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.sales-backfill-row-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.sales-backfill-row-head span {
  font-size: 11.5px;
  color: var(--muted);
}

.sales-backfill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}

.sales-backfill-grid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sales-backfill-grid span {
  font-size: 11px;
  color: var(--muted);
}

.sales-backfill-grid strong {
  font-size: 12.5px;
}

/* ── API 测试台 (api-tester) ── */
.api-tester-headers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.api-tester-header-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
}

.api-tester-header-row input {
  width: 100%;
}

.api-tester-header-remove {
  padding: 0 10px;
  font-size: 16px;
  line-height: 1;
}

.api-tester-orders-day-tools {
  border: 1px dashed var(--border-color, rgba(0, 0, 0, 0.14));
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(59, 130, 246, 0.03);
}

.api-tester-orders-day-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.api-tester-orders-day-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted, #666);
}

.api-tester-orders-day-grid select,
.api-tester-orders-day-grid input {
  width: 100%;
}

@media (max-width: 920px) {
  .api-tester-orders-day-grid {
    grid-template-columns: 1fr;
  }
}

.api-tester-history-wrap {
  margin-top: 18px;
}

.api-tester-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.api-tester-history-head h3 {
  margin: 0;
  font-size: 14px;
}

.api-tester-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.api-tester-history-item {
  display: grid;
  grid-template-columns: 60px 1fr 50px;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
}

.api-tester-history-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.api-tester-history-method {
  font-weight: 700;
}

.api-tester-history-method.ok {
  color: #16a34a;
}

.api-tester-history-method.error {
  color: #dc2626;
}

.api-tester-history-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-tester-history-status {
  text-align: right;
  color: var(--text-muted, #666);
}

/* ── 商品管理 (my-listings) ── */
.view#my-listings .surface {
  border-radius: 16px;
  border: 1px solid #e5eaf2;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

#my-listings .content-grid {
  gap: 10px;
  align-items: start;
}

#my-listings .surface.span-12 {
  padding: 12px 12px 8px;
}

#my-listings .section-heading {
  position: sticky;
  top: 86px;
  z-index: 8;
  margin: 4px 0 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 250, 255, 0.92));
  backdrop-filter: blur(10px);
  border: 1px solid #e5eaf2;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

#my-listings .listings-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 2px 0 12px;
}

#my-listings .listings-stat-card {
  appearance: none;
  text-align: left;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  cursor: pointer;
  display: grid;
  gap: 4px;
  min-width: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

#my-listings .listings-stat-card:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

#my-listings .listings-stat-card.is-selected {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

#my-listings .listings-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

#my-listings .listings-stat-card strong {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  letter-spacing: -0.02em;
}

#my-listings .listings-stat-hint {
  font-size: 11px;
  color: #94a3b8;
}

#my-listings .listings-stat-card.is-active strong { color: #15803d; }
#my-listings .listings-stat-card.is-paused strong { color: #b45309; }
#my-listings .listings-stat-card.is-critical strong { color: #b91c1c; }
#my-listings .listings-stat-card.is-oos strong { color: #7c2d12; }

#my-listings .listings-stat-card.is-critical {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff7f7 0%, #fff 100%);
}

#my-listings .listings-stat-card.is-oos {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fffaf5 0%, #fff 100%);
}

#my-listings .listings-toolbar-stacked {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

#my-listings .listings-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
}

#my-listings .listings-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

#my-listings .listings-toolbar-secondary {
  padding-top: 8px;
  border-top: 1px solid #eef2f7;
}

#my-listings .listings-quick-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

#my-listings .listings-quick-chip {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 650;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

#my-listings .listings-quick-chip:hover {
  border-color: #cbd5e1;
  color: #0f172a;
  background: #f8fafc;
}

#my-listings .listings-quick-chip.is-active {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px rgba(147, 197, 253, 0.45);
}

#my-listings .listings-summary {
  flex: 1;
  justify-content: flex-end;
}

#my-listings .listings-summary-meta {
  display: none;
}

#my-listings .listings-summary-tools {
  margin-left: auto;
}

#my-listings .search-box.compact {
  min-width: 220px;
  width: min(320px, 42vw);
}

#my-listings .listing-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

#my-listings .listings-table td {
  padding: 9px 10px;
}

#my-listings .listings-table tbody tr.listing-row:hover td {
  background: #f5f9ff;
}

#my-listings .listing-stock-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

#my-listings .listing-stock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #86efac;
  flex-shrink: 0;
}

#my-listings .listing-stock-cell.is-ok { color: #166534; }
#my-listings .listing-stock-cell.is-low {
  color: #b45309;
}
#my-listings .listing-stock-cell.is-low .listing-stock-dot {
  background: #fbbf24;
}
#my-listings .listing-stock-cell.is-zero {
  color: #b91c1c;
}
#my-listings .listing-stock-cell.is-zero .listing-stock-dot {
  background: #f87171;
}

#my-listings .listing-action-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

#my-listings .listing-action-group .listing-action-btn.primary {
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
}

#my-listings .listing-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

#my-listings .listing-action-icon:hover {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

#my-listings .listings-table-wrap {
  border-radius: 16px;
  border-color: #e2e8f0;
}

#my-listings .listings-pager {
  margin-top: 8px;
  padding: 8px 4px 2px;
  border-top-color: #eef2f7;
}

#my-listings .listing-variants-toggle {
  margin-top: 6px;
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #f8fbff, #eff6ff);
  color: #1d4ed8;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 650;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

#my-listings .listing-variants-toggle:hover {
  border-color: #93c5fd;
  background: #dbeafe;
  transform: translateY(-1px);
}

#my-listings .chip.success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

#my-listings .listings-table th {
  letter-spacing: 0.01em;
}

@media (max-width: 1100px) {
  #my-listings .listings-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  #my-listings .listings-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #my-listings .listings-toolbar-actions {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  #my-listings .search-box.compact {
    width: 100%;
    min-width: 0;
  }
}

.wip-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.listings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}

.listings-filter-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.listings-filter-controls select {
  min-width: 96px;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px solid #d8e0ea;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  font-size: 13px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

#listingsAccountSelect {
  width: 108px;
  min-width: 108px;
  max-width: 108px;
  padding-left: 7px;
  padding-right: 22px;
  font-size: 12px;
  text-overflow: ellipsis;
}

#listingsCountrySelect {
  width: 102px;
  min-width: 102px;
  max-width: 102px;
}

.listings-filter-controls select:hover {
  border-color: #bfd0e4;
}

.listings-filter-controls select:focus {
  outline: none;
  border-color: #d8e0ea;
  box-shadow: none;
}

.listings-sync-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#listingsSyncSettingsSection {
  margin-top: 14px;
}

#listingsSyncSettingsSection .user-settings-section-head p {
  line-height: 1.65;
  color: #64748b;
}

#listingsSyncSettingsSection .orders-sync-settings-body {
  border-radius: 16px;
}

#listingsSyncSettingsSection .user-settings-option {
  border-radius: 14px;
}

#listingsSyncSettingsSection .user-settings-field {
  border-radius: 14px;
}

#listingsSyncStatusWrap {
  align-items: flex-start;
}

#listingsSyncStatusLine {
  line-height: 1.55;
}

.listings-sort-label {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  color: #475569;
  font-weight: 600;
}

.listings-sort-arrows {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  line-height: 0.7;
  font-size: 9px;
  gap: 1px;
  transform: translateY(1px);
}

.listings-sort-arrow-btn {
  border: none;
  background: transparent;
  color: #64748b;
  padding: 0;
  width: 14px;
  height: 12px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 600;
  opacity: 0.92;
  border-radius: 4px;
  transition: color 120ms ease, opacity 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.listings-sort-arrow-btn:hover {
  color: #334155;
  opacity: 1;
}

.listings-sort-arrow-btn.is-on {
  color: #2563eb;
  opacity: 1;
  font-weight: 700;
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px #93c5fd;
}

#profit-analysis .listings-sort-arrow-btn.is-on {
  color: #2563eb;
  opacity: 1;
  font-weight: 700;
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px #93c5fd;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: linear-gradient(180deg, #f3f7fc, #eef3fa);
  border-radius: 10px;
  border: 1px solid #d9e3ef;
}

.segmented-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.segmented-btn:hover {
  color: #1f2937;
  transform: translateY(-1px);
}

.segmented-btn.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.search-box.compact {
  min-width: 180px;
}

.listings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--ink-secondary);
}

.listings-summary-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.listings-summary-meta > span {
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listings-summary-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 0;
  flex: 0 1 auto;
  min-width: 0;
}

.listings-state {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.listings-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  height: auto;
  max-height: none;
  border: 1px solid #e6edf6;
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.listings-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}

.listings-col-product,
.listings-table th.listings-th-product,
.listings-table td.listings-td-product,
.listings-table .listings-sticky-left {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  box-sizing: border-box;
}

.listings-table th {
  text-align: left;
  padding: 8px 10px;
  color: #5b6b80;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid #e6edf6;
  white-space: nowrap;
  background: #f8fbff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.listings-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #eef3f8;
  vertical-align: middle;
  background: #fff;
}

.listings-table th.listings-th-status,
.listings-table td:nth-child(2) {
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

.listings-table th.listings-th-num,
.listings-table td.listings-td-num {
  text-align: center;
  padding-left: 6px;
  padding-right: 6px;
  font-variant-numeric: tabular-nums;
}

.listings-table th.listings-th-action,
.listings-table td.listing-actions {
  text-align: center;
  padding: 7px 4px;
}

.listings-th-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.listings-table th.listings-th-num .listings-sort-label {
  margin-right: 0;
  font-size: 11.5px;
}

.listings-table thead th.listings-metric-head {
  background: #f4f8fd;
}

.listings-table tbody td.listings-td-metric {
  background: #fbfcfe;
}

.listings-table tbody tr:hover td {
  background: #f8fafc;
}

.listings-table tbody tr:hover td.listings-td-metric {
  background: #f3f7fb;
}

.listings-table .listings-sticky-left {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  box-shadow: 1px 0 0 #e8eef4;
  overflow: hidden;
}

.listings-table thead th.listings-sticky-left {
  top: 0;
  z-index: 6;
  background: #f8fbff;
}

.listings-table .listings-sticky-right {
  position: sticky;
  z-index: 3;
  background: #fff;
}

.listings-table thead th.listings-sticky-right {
  top: 0;
  z-index: 5;
  background: #f8fbff;
}

.listings-table thead th.listings-sticky-right.listings-metric-head {
  background: #f4f8fd;
}

.listings-table tbody td.listings-sticky-right.listings-td-metric {
  background: #fbfcfe;
}

.listings-table .listings-sticky-right.is-sticky-right-edge {
  box-shadow: -1px 0 0 #e8eef4;
}

.listings-table tbody tr:hover td.listings-sticky-left,
.listings-table tbody tr:hover td.listings-sticky-right {
  background: #f8fafc;
}

.listings-table tbody tr:hover td.listings-sticky-right.listings-td-metric {
  background: #f3f7fb;
}

.listings-table td.listings-td-product,
.listings-table td.listings-sticky-left {
  padding-right: 12px;
}

.listings-table td.listings-sticky-left .listing-cell-copy strong {
  font-size: 13px;
  line-height: 1.35;
}

.listings-avg-sales-inner {
  gap: 3px;
}

.listings-metric-select {
  width: 50px;
  min-width: 50px;
  max-width: 50px;
  padding: 1px 16px 1px 4px;
  border-radius: 6px;
  border: 1px solid #d8e0ea;
  background: #fff;
  font-size: 11px;
  color: #475569;
  flex: 0 0 auto;
  cursor: pointer;
}

.listing-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.listing-cell-btn {
  width: 100%;
  justify-content: flex-start;
}

.listing-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.listing-thumb.placeholder {
  display: inline-block;
  border: 1px dashed #cbd5e1;
}

.listing-cell-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.listing-cell-copy strong {
  display: block;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-variants-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
  margin-left: 0;
  width: fit-content;
  max-width: 100%;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  vertical-align: middle;
}

.listing-cell-copy strong a {
  color: #1d4ed8;
  text-decoration: none;
}

.listing-cell-copy strong a:hover {
  text-decoration: underline;
}

.listing-cell-meta {
  font-size: 11px;
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.listing-cell-meta-sub,
.listing-detail-id-sub {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.85;
}

.listing-detail-id-sub {
  margin: 2px 0 0;
}

.chip.tiny {
  padding: 1px 6px;
  font-size: 10px;
}

.listing-metric-pending {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.listing-actions {
  white-space: nowrap;
  vertical-align: middle;
}

.listing-action-link {
  display: inline-block;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0 auto;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.listing-action-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.listing-variants-toggle {
  margin-top: 6px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
}

.listing-variants-row td {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding-top: 8px;
  padding-bottom: 8px;
}

.listing-variants-panel {
  display: grid;
  gap: 6px;
}

.listing-variant-item {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(8, minmax(56px, 1fr));
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  color: #475569;
}

.listing-variant-item > span:not(.listing-variant-name-wrap) {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.listing-variant-metric {
  display: block;
  text-align: center;
}

.listing-variant-item strong {
  color: #0f172a;
  font-size: 12.5px;
}

.listing-variant-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.listing-variant-name-copy {
  display: grid;
  min-width: 0;
}

.listing-variant-name-copy span {
  color: #64748b;
  font-size: 11.5px;
}

.listing-variant-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #e2e8f0;
  flex: 0 0 auto;
}

.listing-variant-thumb.placeholder {
  background: #f1f5f9;
}

.listing-metric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #334155;
}

.listing-metric-muted {
  color: #94a3b8;
}

.listing-metric-value.is-warn {
  color: #dc2626;
}

.listing-metric-value.is-days-critical {
  color: #b91c1c;
  font-weight: 700;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  padding: 1px 6px;
  border-radius: 5px;
}

.listing-metric-value.is-days-caution {
  color: #b45309;
  font-weight: 600;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  padding: 1px 6px;
  border-radius: 5px;
}

.listing-metric-value.is-days-ok {
  color: #15803d;
  font-weight: 600;
}

.listing-metric-value.is-estimated {
  color: #64748b;
}

.listing-in-transit-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.listing-in-transit-cell:hover {
  border-color: #94a3b8;
  background: #fff;
}

.listing-in-transit-input {
  width: 52px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}

.listing-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
  text-decoration: none;
}

.listing-action-btn:hover:not(:disabled):not(.is-disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.listing-action-btn.primary {
  color: #1e40af;
  border-color: #c6dafc;
  background: linear-gradient(180deg, #f3f8ff, #e9f1ff);
}

.listing-action-btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #eaf2ff, #dceaff);
  border-color: #9fc2fb;
  transform: translateY(-1px);
}

.listing-action-btn.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.listing-action-btn.ghost {
  background: #f8fafc;
}

.listing-action-btn.is-disabled,
.listing-action-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
}

.listing-cell-btn {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
  transition: background 140ms ease;
}

.listing-cell-btn:hover {
  background: #f8fafc;
}

.listing-row:hover td {
  background: #f6faff;
}

@media (max-width: 960px) {
  .listings-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .listings-summary {
    order: 4;
    width: 100%;
  }

  .listings-toolbar .search-box.compact {
    width: 100%;
    min-width: 0;
  }

  #my-listings .section-heading {
    top: 76px;
    padding: 9px;
  }

  .listings-table-wrap {
    height: auto;
    max-height: none;
  }

  #my-listings .surface.span-12 {
    padding: 8px 6px 4px;
  }

  #listingsAccountSelect,
  #listingsCountrySelect {
    min-width: 0;
    max-width: none;
  }
}

body.listing-detail-open {
  overflow: hidden;
}

.listing-detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: 1fr min(560px, 100vw);
}

.listing-detail-drawer[hidden] {
  display: none;
}

.listing-detail-backdrop {
  border: none;
  background: rgba(15, 23, 42, 0.38);
  cursor: pointer;
}

.listing-detail-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
  max-height: 100vh;
}

.listing-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e8edf3;
}

.listing-detail-eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.listing-detail-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  max-width: 420px;
}

.listing-detail-close {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.listing-detail-body {
  overflow: auto;
  padding: 0 0 24px;
}

.listing-detail-gallery {
  background: #f8fafc;
  border-bottom: 1px solid #e8edf3;
}

.listing-detail-gallery.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 13px;
}

.listing-detail-hero {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 20px;
}

.listing-detail-hero img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.listing-detail-thumbs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  overflow-x: auto;
}

.listing-detail-thumb {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.listing-detail-thumb.active {
  border-color: #2563eb;
}

.listing-detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.listing-detail-content {
  padding: 18px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.listing-detail-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.listing-detail-id {
  margin: 0 0 6px;
  font-size: 12px;
  color: #64748b;
}

.listing-detail-name {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
}

.listing-detail-price {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
}

.listing-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e8edf3;
}

.listing-detail-meta-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.listing-detail-meta-row.span-2 {
  grid-column: 1 / -1;
}

.listing-detail-meta-row > span {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

.listing-detail-meta-row > strong,
.listing-detail-meta-row > div {
  font-size: 13px;
  color: #0f172a;
  word-break: break-word;
}

.listing-detail-marketplaces {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.listing-detail-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

.listing-detail-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.listing-detail-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
}

.listing-detail-edit-tip {
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
  margin: 0 0 10px;
}

.listing-detail-readonly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.listing-detail-readonly-grid div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.listing-detail-readonly-grid span {
  font-size: 12px;
  color: #64748b;
}

.listing-detail-readonly-grid strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}

.listing-detail-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.listing-detail-form label span {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.listing-detail-form input {
  height: 38px;
  border-radius: 10px;
  border: 1px solid #dbe3ee;
  padding: 0 12px;
  font-size: 14px;
}

.listing-detail-form input:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.primary-button.compact {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
}

.listing-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.listing-detail-description {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e8edf3;
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

.listing-detail-attrs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.listing-detail-attr {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e8edf3;
}

.listing-detail-attr span {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}

.listing-detail-attr strong {
  font-size: 13px;
  color: #0f172a;
  word-break: break-word;
}

.listings-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  padding: 2px 0 0;
  font-size: 13px;
  color: #6b7280;
  border-top: 1px solid #e7edf5;
}

/* display:flex 会盖掉原生 [hidden] */
.listings-pager[hidden],
.listings-table-wrap[hidden],
.listings-stats[hidden],
.listings-summary[hidden],
.listings-state[hidden] {
  display: none !important;
}

.listings-toolbar > .ghost-button.compact,
.listings-toolbar .segmented {
  flex: 0 0 auto;
}

.listings-toolbar .search-box.compact {
  min-width: 260px;
  width: min(360px, 38vw);
}

.listings-toolbar .listings-sync-badge {
  max-width: 500px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#listingsPageInfo {
  min-width: 136px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.01em;
}

#profitPageInfo {
  min-width: 136px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.01em;
}

.listings-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}

.listings-page-size label {
  font-size: 12px;
  color: #64748b;
}

.listings-page-size select {
  height: 34px;
  border-radius: 10px;
  border: 1px solid #d8e3f0;
  background: #fff;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.listings-page-numbers {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.listings-page-btn {
  min-width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #d9e3ef;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.listings-page-btn:hover {
  transform: translateY(-1px);
  border-color: #bcd0ea;
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.12);
}

.listings-page-btn.is-active {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: linear-gradient(180deg, #f0f7ff, #e2efff);
}

.listings-page-ellipsis {
  color: #94a3b8;
  font-weight: 700;
  padding: 0 2px;
}

.listings-pager .ghost-button.compact {
  min-width: 112px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid #d8e3f0;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  color: #334155;
  font-weight: 700;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.listings-pager .ghost-button.compact:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #bcd0ea;
  background: linear-gradient(180deg, #ffffff, #edf5ff);
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.12);
}

.listings-pager .ghost-button.compact:disabled {
  opacity: 0.55;
  color: #94a3b8;
  background: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: none;
}

@media (max-width: 960px) {
  .listings-pager {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 1100px) {
  .agent-monitor-layout {
    grid-template-columns: 1fr;
  }

  .item-lookup-form {
    grid-template-columns: 1fr;
  }

  .item-lookup-options-grid,
  .item-lookup-fields-grid {
    grid-template-columns: 1fr 1fr;
  }

  .item-lookup-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-lookup-insight-grid {
    grid-template-columns: 1fr;
  }

  .agent-monitor-panels {
    grid-template-columns: 1fr;
  }

  .agent-monitor-panel.span-2 {
    grid-column: span 1;
  }
}

/* ===== Sales Overview (销售总览) ===== */
.sales-overview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sales-overview.is-refreshing .sales-head-info p::after {
  content: " · 更新中";
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.sales-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
}

.sales-filter-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.sales-filter-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sales-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.sales-filter-group-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.sales-filter-group select {
  height: 100%;
  min-width: 118px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

.sales-account-picker {
  position: relative;
}

.sales-account-picker-btn {
  height: 100%;
  min-width: 120px;
  max-width: 200px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-account-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  max-width: 320px;
  max-height: 280px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.sales-account-picker-menu[hidden] {
  display: none;
}

.sales-account-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.35;
}

.sales-account-option:hover {
  background: #f1f5f9;
}

.sales-account-option input {
  margin-top: 2px;
  flex-shrink: 0;
}

.sales-account-option-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sales-account-option-body strong {
  font-size: 12.5px;
  color: var(--ink);
}

.sales-account-option-body span {
  font-size: 11px;
  color: var(--muted);
}

.sales-account-picker-actions {
  display: flex;
  gap: 6px;
  padding: 6px 4px 4px;
  border-top: 1px solid #e8edf3;
  margin-top: 4px;
}

.sales-account-picker-actions button {
  flex: 1;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.sales-account-picker-actions button.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.sales-range-segmented {
  flex-shrink: 0;
  height: 40px;
  align-items: center;
}

.sales-head-info h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.sales-head-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.sales-custom-range-anchor {
  position: relative;
  display: inline-flex;
}

.sales-custom-range-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  width: min(320px, calc(100vw - 32px));
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 12px;
}

.sales-custom-range-popover[hidden] {
  display: none !important;
}

.sales-custom-range-popover-head {
  display: grid;
  gap: 4px;
}

.sales-custom-range-popover-head strong {
  font-size: 13px;
  color: var(--ink);
}

.sales-custom-range-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.sales-custom-range-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.sales-custom-range-sep {
  display: none;
}

.sales-custom-calendar-wrap {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sales-custom-calendar-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sales-custom-calendar {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fafbfc;
  min-height: 248px;
}

.sales-cal-error {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  color: #b45309;
  padding: 12px;
}

.sales-cal-selected {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  margin-bottom: 6px;
}

.sales-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.sales-cal-month {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.sales-cal-nav-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.sales-cal-nav-btn:hover {
  background: #f1f5f9;
}

.sales-cal-weekdays,
.sales-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.sales-cal-weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  padding: 2px 0 4px;
}

.sales-cal-day {
  height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.sales-cal-day.blank {
  pointer-events: none;
}

.sales-cal-day:hover:not(.disabled):not(.selected) {
  background: #e2e8f0;
}

.sales-cal-day.in-range {
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 0;
}

.sales-cal-day.range-start,
.sales-cal-day.range-end {
  background: #2563eb;
  color: #fff;
}

.sales-cal-day.range-start.range-end {
  border-radius: 7px;
}

.sales-cal-day.range-start:not(.range-end) {
  border-radius: 7px 0 0 7px;
}

.sales-cal-day.range-end:not(.range-start) {
  border-radius: 0 7px 7px 0;
}

.sales-cal-day.in-range:hover:not(.disabled) {
  background: #bfdbfe;
}

.sales-cal-day.range-start:hover:not(.disabled),
.sales-cal-day.range-end:hover:not(.disabled) {
  background: #1d4ed8;
}

.sales-cal-day.today:not(.in-range) {
  box-shadow: inset 0 0 0 1px #94a3b8;
}

.sales-cal-day.selected {
  background: #2563eb;
  color: #fff;
}

.sales-cal-day.disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.sales-custom-range-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sales-custom-range-actions .primary-button.compact,
.sales-custom-range-actions .ghost-button.compact {
  height: 34px;
  padding: 0 14px;
  font-size: 12.5px;
  white-space: nowrap;
}

.sales-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}

a.sales-link:hover,
button:hover .sales-link,
.sales-product-row:hover .sales-link,
.sales-side-top-btn:hover .sales-link {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sales-performance-panel.surface {
  padding: 10px 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
}

.sales-performance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sales-performance-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.sales-performance-toggle-action {
  color: #2563eb;
}

.sales-performance-stores {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.sales-performance-stores[hidden] {
  display: none;
}

.sales-performance-head,
.sales-daily-head {
  flex-shrink: 0;
  margin-bottom: 8px;
}

.sales-chart-card,
.sales-products-card {
  padding: 10px 12px;
}

.sales-chart-card .section-heading.compact {
  margin-bottom: 8px;
  gap: 10px;
}

.sales-chart-card .section-heading h2 {
  font-size: 14px;
  flex: 0 0 auto;
}

.sales-chart-card .sales-chart-head-actions {
  flex: 1 1 auto;
}

.sales-trend-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 14px;
  align-items: start;
}

.sales-chart-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  flex: 1 1 auto;
}

.sales-chart-board.is-dual {
  min-height: 0;
  gap: 4px;
}

.sales-chart-board.is-dual .sales-chart-panel {
  flex: 0 0 auto;
  gap: 2px;
}

.sales-chart-board.is-dual .sales-line-wrap {
  flex: 0 0 158px;
  height: 158px;
  min-height: 158px;
}

.sales-chart-board.is-dual .sales-line-chart {
  min-height: 0;
  height: 158px !important;
  max-height: 158px;
}

.sales-trend-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.sales-side-block--top {
  min-width: 0;
  overflow: hidden;
}

.sales-side-block {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e8edf3;
}

.sales-side-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}

.sales-side-copy,
.sales-side-meta {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.sales-side-copy strong {
  color: #1d4ed8;
}

.sales-side-progress {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.sales-side-progress.is-active > div {
  background: linear-gradient(90deg, #60a5fa, #2563eb, #60a5fa);
  background-size: 200% 100%;
  animation: sales-sync-progress 1.2s linear infinite;
}

.sales-side-progress > div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width 0.18s ease;
}

.sales-sync-status.is-live {
  color: #1d4ed8;
  font-weight: 600;
}

.sales-sync-status.is-pulling {
  color: #1d4ed8;
}

.sales-sync-status.is-stale {
  color: #b45309;
  font-weight: 600;
}

.sales-sync-detail {
  margin-top: 4px;
  font-size: 11.5px;
  color: #64748b;
}

.sales-sync-detail.is-empty {
  display: none;
}

.sales-sync-flash {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 11.5px;
  font-weight: 600;
}

.sales-sync-flash[hidden] {
  display: none;
}

.sales-sync-status.is-live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #2563eb;
  animation: sales-sync-pulse 1s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes sales-sync-progress {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@keyframes sales-sync-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}

.sales-side-meta {
  margin-top: 8px;
  font-size: 12px;
}

.sales-side-status-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  margin-top: 6px;
}

.sales-side-status-row:first-of-type {
  margin-top: 0;
}

.sales-side-status-bar {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.sales-side-status-bar > div {
  height: 100%;
  background: #2563eb;
  border-radius: inherit;
}

.sales-side-top-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sales-side-top-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sales-side-top-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.sales-side-top-btn:hover .sales-side-top-title {
  color: #1d4ed8;
}

.sales-side-metric-list {
  display: grid;
  gap: 8px;
}

.sales-side-metric-list div,
.sales-side-metric-list .sales-side-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.sales-side-metric-list span {
  color: var(--muted);
}

.sales-side-metric-list strong {
  color: var(--ink);
}

.sales-performance-panel,
.sales-daily-panel {
  border-radius: 12px;
}

.sales-daily-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e8edf3;
  overflow: hidden;
}

.sales-performance-head h3,
.sales-daily-head h3 {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

.sales-performance-head p,
.sales-daily-head p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.sales-performance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.sales-performance-grid.is-wide {
  grid-template-columns: repeat(var(--sales-perf-cols, 7), minmax(0, 1fr));
  gap: 4px;
}

.sales-performance-grid.is-wide .sales-performance-card {
  padding: 5px 6px;
  gap: 1px;
}

.sales-performance-grid.is-wide .sales-performance-card span {
  font-size: 10px;
}

.sales-performance-grid.is-wide .sales-performance-card strong {
  font-size: 12.5px;
}

.sales-performance-grid.is-wide .sales-performance-value-row {
  gap: 3px;
  flex-wrap: wrap;
}

.sales-performance-grid.is-wide .sales-performance-cny-tag {
  font-size: 9px;
}

.sales-performance-grid.is-wide .sales-performance-compare {
  font-size: 10px;
}

.sales-performance-card {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e8edf3;
  min-width: 0;
  overflow: hidden;
}

.sales-performance-card.accent {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #f0f7ff 0%, #fff 100%);
}

.sales-performance-card.is-tax-warn {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #fff 100%);
}

.sales-performance-card.is-tax-warn strong {
  color: #b45309;
}

.sales-performance-card.is-spacer {
  visibility: hidden;
  pointer-events: none;
  border: none;
  background: transparent;
  box-shadow: none;
}

.sales-performance-card.is-clickable {
  cursor: pointer;
}

.sales-performance-card.is-clickable:hover {
  border-color: #93c5fd;
  box-shadow: 0 1px 0 rgba(37, 99, 235, 0.08);
}

.sales-side-metric-row {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.sales-side-metric-row.is-clickable {
  cursor: pointer;
}

.sales-side-metric-row.is-clickable:hover strong {
  color: #1d4ed8;
}

.sales-performance-card-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}

.sales-performance-cny-tag {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  font-style: normal;
  white-space: nowrap;
  flex-shrink: 0;
}

.sales-performance-card span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.sales-performance-card strong {
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.sales-performance-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.sales-performance-value-row strong {
  min-width: 0;
}

.sales-performance-compare {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.sales-performance-compare.is-up {
  color: #16a34a;
}

.sales-performance-compare.is-down {
  color: #dc2626;
}

.sales-performance-compare.is-flat {
  color: var(--muted);
}

.sales-performance-card.accent strong {
  color: #1d4ed8;
}

.sales-performance-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e8edf3;
}

.sales-performance-section.store {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e8edf3;
}

.sales-performance-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.sales-performance-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sales-performance-section-head h4 {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

.sales-performance-section-head span {
  font-size: 11px;
  color: var(--muted);
}

.sales-performance-section-head.compact {
  margin-bottom: 4px;
}

.sales-performance-section-head.compact h4 {
  font-size: 12px;
}

.sales-performance-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.sales-performance-grid.compact.is-wide {
  grid-template-columns: repeat(var(--sales-perf-cols, 7), minmax(0, 1fr));
  gap: 4px;
}

.sales-performance-grid.compact .sales-performance-card {
  padding: 5px 6px;
}

.sales-performance-grid.compact .sales-performance-card strong {
  font-size: 13px;
}

.sales-chart-board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sales-chart-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sales-chart-panel[hidden] {
  display: none !important;
}

.sales-chart-panel-head {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

.sales-chart-panel--profit .sales-chart-panel-head {
  color: #15803d;
}

.sales-line-wrap--profit {
  min-height: 160px;
}

.sales-chart-view-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  color: var(--ink);
}

.sales-chart-metric-toggles {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.sales-metric-toggle {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  white-space: nowrap;
}

.sales-metric-toggle:hover {
  border-color: #cbd5e1;
  color: #334155;
}

.sales-metric-toggle.is-on[data-metric="sales"] {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.sales-metric-toggle.is-on[data-metric="profit"] {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.sales-metric-toggle.is-on[data-metric="margin"] {
  background: #fff7ed;
  border-color: #fdba74;
  color: #c2410c;
}

.sales-metric-toggle.is-on[data-metric="roi"] {
  background: #fdf2f8;
  border-color: #f9a8d4;
  color: #be185d;
}

.sales-metric-toggle.is-on[data-metric="units"] {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
}

.sales-metric-toggle.is-on[data-metric="orders"] {
  background: #f5f3ff;
  border-color: #c4b5fd;
  color: #6d28d9;
}

.sales-line-chart--multi .sales-line-grid-label--right {
  fill: #15803d;
}

.sales-mini-chart-metric--multi {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.sales-line-wrap--main {
  min-height: 220px;
}

.sales-line-chart--profit .sales-line-path {
  stroke: #16a34a;
}

.sales-line-chart--profit .sales-line-dot {
  fill: #16a34a;
}

.sales-line-dot--pending,
.sales-line-chart--profit .sales-line-dot--pending {
  fill: #fff;
  stroke: #f59e0b;
  stroke-width: 2px;
}

.sales-line-chart--units .sales-line-grid-label {
  fill: #475569;
  font-size: 10px;
}

.sales-chart-board-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0;
}

.sales-chart-board-stores {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.sales-chart-board-stores[hidden] {
  display: none;
}

.sales-mini-chart-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 200px;
  min-width: 200px;
  max-width: 220px;
  padding: 8px 10px 6px;
  border-radius: 10px;
  border: 1px solid #e8edf3;
  background: #fff;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  align-self: flex-start;
}

.sales-mini-chart-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.08);
}

.sales-mini-chart-card.has-profit {
  flex: 0 0 220px;
  min-width: 220px;
  max-width: 240px;
}

.sales-mini-chart-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sales-mini-chart-block--profit .sales-mini-chart-label {
  color: #15803d;
}

.sales-mini-chart-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.sales-chart-modal-panels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.sales-mini-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sales-mini-chart-head h4 {
  margin: 0;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-mini-chart-expand {
  font-size: 11px;
  color: #2563eb;
  font-weight: 600;
  white-space: nowrap;
}

.sales-mini-chart-metric {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.sales-mini-chart-metric strong {
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.sales-mini-chart-metric span {
  font-size: 11px;
  color: #16a34a;
  font-weight: 700;
}

.sales-mini-chart-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.sales-line-wrap.sales-line-wrap--mini {
  width: 100%;
  min-height: 0;
  height: 76px;
  max-height: 76px;
  flex: 0 0 76px;
  overflow: hidden;
}

.sales-line-wrap--mini .sales-line-chart,
.sales-line-chart--mini {
  width: 100%;
  min-height: 0;
  height: 76px;
  max-height: 76px;
  display: block;
}

.sales-line-wrap--mini .sales-line-path {
  stroke-width: 2;
}

.sales-line-xlabel--mini {
  font-size: 9px;
  fill: #94a3b8;
}

.sales-line-point.compact .sales-line-dot {
  fill: #fff;
  stroke: #2f6fe4;
  stroke-width: 1.5;
}

.sales-line-point.compact:hover .sales-line-dot {
  transform: scale(1.35);
}

.sales-line-wrap--main {
  flex: 1 1 auto;
}

.sales-chart-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.sales-chart-modal-card {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  padding: 16px 18px 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2);
}

.sales-line-wrap--modal {
  min-height: 360px;
}

.sales-line-wrap--modal .sales-line-chart {
  min-height: 360px;
}

.sales-daily-table-wrap {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.sales-daily-table,
.sales-item-orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.sales-daily-table th,
.sales-daily-table td,
.sales-item-orders-table th,
.sales-item-orders-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e8edf3;
  text-align: left;
  white-space: nowrap;
}

.sales-daily-table th,
.sales-item-orders-table th {
  color: var(--muted);
  font-weight: 700;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.sales-product-row {
  cursor: pointer;
}

.sales-product-row:hover {
  background: #f8fbff;
}

.sales-item-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.sales-item-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.sales-item-modal-card {
  position: relative;
  width: min(920px, 100%);
  max-height: min(80vh, 760px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.sales-item-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid #e8edf3;
}

.sales-item-modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.sales-item-modal-head p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.sales-item-modal-body {
  padding: 0 20px 20px;
  overflow: auto;
}

.sales-side-top-title {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-side-top-meta {
  font-size: 11.5px;
  color: var(--muted);
}

.sales-chart-head-actions {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr);
  align-items: center;
  column-gap: 12px;
  width: min(100%, 920px);
  min-width: 0;
  margin-left: auto;
}

.sales-chart-hint,
#salesChartHint.sales-chart-hint {
  justify-self: stretch;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.sales-line-chart--multi .sales-line-grid-label--right.is-percent {
  fill: #c2410c;
}

@media (max-width: 1100px) {
  .sales-chart-head-actions {
    width: 100%;
    grid-template-columns: 1fr;
    row-gap: 6px;
  }

  .sales-chart-metric-toggles {
    flex-wrap: wrap;
  }

  .sales-chart-hint,
  #salesChartHint.sales-chart-hint {
    text-align: left;
  }
}

.sales-line-wrap {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 158px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.sales-line-wrap .sales-line-chart {
  flex: 1 1 auto;
  min-height: 0;
}

.sales-line-chart {
  width: 100%;
  min-height: 200px;
  height: auto;
  display: block;
  overflow: visible;
}

.sales-line-grid {
  stroke: #e9eef5;
  stroke-width: 1;
}

.sales-line-grid-label {
  font-size: 11px;
  fill: #9aa9bd;
}

.sales-line-area {
  fill: url(#salesAreaGradient);
}

.sales-chart-tooltip {
  position: fixed;
  z-index: 1200;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
  display: none;
  gap: 2px;
  min-width: 140px;
}

.sales-chart-tooltip:not([hidden]) {
  display: grid;
}

.sales-chart-tooltip strong {
  font-size: 13px;
  margin-bottom: 2px;
}

.sales-line-path {
  fill: none;
  stroke: #2f6fe4;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(47, 111, 228, 0.15));
}

.sales-line-dot-hit {
  fill: transparent;
  cursor: pointer;
}

.sales-line-dot {
  fill: #2f6fe4;
  stroke: #fff;
  stroke-width: 2.5;
  pointer-events: none;
}

.sales-line-point:hover .sales-line-dot {
  fill: #1d4ed8;
  stroke-width: 3;
}

.sales-line-xlabel {
  font-size: 11px;
  fill: #6b7c93;
}

.sales-products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sales-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sales-product-card {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #e8edf3;
  border-radius: 12px;
  background: #fff;
}

.sales-product-card-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}

.sales-product-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #e8edf3;
  background: #f8fafc;
}

.sales-product-thumb.compact {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.sales-product-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
}

.sales-product-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sales-product-card-title,
.sales-side-product-title {
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.sales-product-card-meta,
.sales-side-product-meta,
.sales-side-product-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-all;
}

.sales-product-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sales-product-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sales-product-metric span {
  font-size: 11px;
  color: var(--muted);
}

.sales-product-metric strong {
  font-size: 13px;
  color: var(--ink);
}

.sales-product-metric.share .sales-product-share {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sales-product-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 92px;
}

.sales-product-actions.compact {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-width: 0;
}

.sales-action-link,
.sales-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.sales-action-link {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.sales-action-link:hover {
  background: #dbeafe;
}

.sales-action-btn {
  color: #334155;
  background: #fff;
  border: 1px solid #d7dee8;
  cursor: pointer;
}

.sales-action-btn:hover {
  background: #f8fafc;
}

.sales-side-product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sales-side-product-card {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-width: 0;
}

.sales-side-product-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

@media (max-width: 1200px) {
  .sales-product-card {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .sales-product-card-metrics {
    grid-template-columns: repeat(3, minmax(72px, 1fr));
  }

  .sales-product-actions {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
  }
}

.sales-products-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid #e8edf3;
}

.sales-products-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.sales-product-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sales-product-cell strong {
  font-weight: 600;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-product-cell span {
  font-size: 11.5px;
  color: var(--muted);
}

.sales-product-share {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  align-items: center;
}

.sales-product-share-bar {
  height: 8px;
  border-radius: 6px;
  background: #f1f5f9;
  overflow: hidden;
}

.sales-product-share-bar > div {
  height: 100%;
  border-radius: 6px;
  background: #3b82f6;
}

.sales-product-share > span {
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.sales-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 200px;
  padding-top: 12px;
  overflow-x: auto;
}

.sales-bar-col {
  flex: 1 0 auto;
  min-width: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.sales-bar-track {
  flex: 1;
  width: 100%;
  max-width: 34px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sales-bar-fill {
  width: 100%;
  max-width: 28px;
  min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  transition: height 220ms ease;
}

.sales-bar-col:hover .sales-bar-fill {
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
}

.sales-bar-label {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.sales-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.sales-status {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.sales-status-row {
  display: grid;
  grid-template-columns: 96px 1fr 56px;
  align-items: center;
  gap: 12px;
}

.sales-status-name {
  font-size: 13px;
  color: var(--ink-secondary, #475569);
  font-weight: 600;
}

.sales-status-bar {
  height: 8px;
  border-radius: 6px;
  background: #f1f5f9;
  overflow: hidden;
}

.sales-status-bar > div {
  height: 100%;
  border-radius: 6px;
  background: #3b82f6;
  transition: width 220ms ease;
}

.sales-status-count {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  text-align: right;
}

@media (max-width: 1200px) {
  .sales-performance-grid,
  .sales-performance-grid.is-wide {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sales-filter-main {
    flex-direction: column;
    align-items: stretch;
  }

  .sales-filter-controls {
    justify-content: flex-start;
  }
}

@media (min-width: 1400px) {
  .sales-line-wrap {
    min-height: 300px;
  }

  .sales-line-chart {
    min-height: 300px;
  }
}

@media (max-width: 900px) {
  .sales-performance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sales-trend-grid {
    grid-template-columns: 1fr;
  }

  .sales-chart-column {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
  }

  .sales-daily-table-wrap {
    max-height: none !important;
  }
}

/* ===== Create Shipment (创建货件) ===== */
.ship-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 6px;
}

.ship-step {
  padding: 16px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: #fbfcfe;
}

.ship-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
}

.ship-step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.ship-step-no.tone-erp {
  background: #7c3aed;
}

.ship-hint {
  margin: 6px 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.ship-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary, #475569);
  margin-bottom: 10px;
}

.ship-field span {
  font-size: 12px;
}

.ship-field input,
.ship-field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

.ship-field.narrow input {
  max-width: 160px;
}

.ship-item-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.ship-field.grow {
  flex: 1;
  margin-bottom: 0;
}

.ship-field.qty {
  width: 100px;
  margin-bottom: 0;
}

.ship-item-del {
  width: 34px;
  height: 38px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 9px;
  background: #fff;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
}

.ship-item-del:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

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

.ship-summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.ship-sum-block {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 14px;
}

.ship-sum-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}

.ship-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.ship-tag.yellow {
  color: #92400e;
  background: #fef3c7;
}

.ship-tag.auto {
  color: #1e40af;
  background: #dbeafe;
}

.ship-tag.erp {
  color: #6b21a8;
  background: #f3e8ff;
}

.ship-sum-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ship-sum-table th,
.ship-sum-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
}

.ship-sum-table th {
  color: var(--muted);
  font-weight: 600;
}

.ship-kv {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}

.ship-kv dt {
  color: var(--muted);
  font-weight: 600;
}

.ship-kv dd {
  margin: 0;
  color: var(--ink);
}

.ship-kv dd small {
  color: var(--muted);
  font-weight: 500;
}

.ship-pending {
  color: #b45309;
  font-weight: 600;
}

.ship-drafts {
  margin: 12px 0 4px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 12px 14px;
  background: #f8fafc;
}

.ship-drafts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.ship-drafts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ship-drafts-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.ship-draft-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 9px;
  background: #fff;
}

.ship-draft-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ship-draft-copy strong {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-draft-copy span {
  font-size: 11.5px;
  color: var(--muted);
}

.ship-draft-ops {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ship-draft-flag {
  align-self: center;
  font-size: 12px;
  color: #16a34a;
  font-weight: 600;
}

.ship-extension-card {
  margin: 12px 0 16px;
  padding: 14px 16px;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: #f8fafc;
}

.ship-extension-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ship-extension-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ship-extension-help {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 12.5px;
  color: var(--ink-secondary, #475569);
}

.ship-extension-help ol {
  margin: 0;
  padding-left: 18px;
}

.ship-extension-help li {
  margin-bottom: 6px;
}

.ship-extension-help code {
  font-size: 11.5px;
  background: #eef2ff;
  padding: 1px 4px;
  border-radius: 4px;
}

.ship-inbound {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.ship-inbound-hint {
  font-size: 12.5px;
  color: #3730a3;
  margin-bottom: 10px;
}

.ship-inbound-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.ship-inbound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 9px;
  font-size: 13px;
}

.ship-inbound-row.bad {
  border-color: #fecaca;
  background: #fef2f2;
}

.ship-inbound-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ship-inbound-title {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.ship-inbound-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  flex-shrink: 0;
}

.ship-up {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
}

.ship-inbound-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
}

.ship-inbound-badge.err {
  background: #fee2e2;
  color: #b91c1c;
}

.ship-inbound-badge.ok {
  background: #dcfce7;
  color: #15803d;
}

.ship-inbound-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.ship-inbound-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #3730a3;
  padding: 8px 0;
}

.ship-inbound-error {
  font-size: 13px;
  color: #b91c1c;
  padding: 8px 0;
}

.ship-inbound-invalid {
  margin: 4px 0 8px;
  padding-left: 18px;
  font-size: 12px;
  color: #b91c1c;
}

.ship-inbound-success .ship-inbound-check {
  font-size: 15px;
  font-weight: 700;
  color: #15803d;
  margin-bottom: 8px;
}

.ship-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #c7d2fe;
  border-top-color: #4f46e5;
  border-radius: 50%;
  display: inline-block;
  animation: ship-spin 0.8s linear infinite;
}

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

.orders-sync-log-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.orders-sync-log-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.orders-sync-log-toolbar .item-lookup-field {
  min-width: 220px;
  margin: 0;
}

.orders-sync-log-auto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted, #64748b);
}

.orders-sync-log-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.orders-sync-log-failed,
.orders-sync-log-events {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.orders-sync-log-failed-row,
.orders-sync-log-event {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.65);
}

.orders-sync-log-failed-row.is-skipped {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(255, 251, 235, 0.7);
}

.orders-sync-log-event.is-error {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(254, 242, 242, 0.75);
}

.orders-sync-log-event.is-warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(255, 251, 235, 0.7);
}

.orders-sync-log-event-head,
.orders-sync-log-failed-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.orders-sync-log-event-head time {
  font-size: 12px;
  color: var(--muted, #64748b);
}

.orders-sync-log-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.orders-sync-log-badge.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.orders-sync-log-badge.is-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.orders-sync-log-mode {
  font-size: 11px;
  color: var(--muted, #64748b);
}

.orders-sync-log-message {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.5;
}

.orders-sync-log-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted, #64748b);
}

.orders-sync-log-payload {
  margin-top: 8px;
}

.orders-sync-log-payload pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.04);
  font-size: 11px;
  overflow: auto;
}

.item-lookup-status.is-warn {
  color: #b45309;
}

.item-lookup-status.is-error {
  color: #b91c1c;
}

.profit-meta {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 12.5px;
}

.profit-exchange-input {
  width: 88px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 12px;
}

.profit-summary-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 14px;
}

.profit-summary-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  display: grid;
  gap: 4px;
  overflow: visible;
}

.profit-summary-card.accent {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #f0f7ff 0%, #fff 100%);
}

.profit-summary-card.is-warn {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}

.profit-summary-card.is-warn strong {
  color: #b45309;
}

.profit-tax-share {
  color: #b45309;
  font-weight: 600;
}

.profit-summary-card-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  color: #64748b;
  font-size: 11px;
  white-space: nowrap;
}

.profit-summary-card.accent strong {
  color: #1d4ed8;
}

.profit-summary-card.is-compact {
  flex: 0.7 1 0;
}

.profit-summary-card.is-wide {
  flex: 1.35 1 0;
}

.profit-summary-card span {
  color: #64748b;
  font-size: 11px;
}

.profit-summary-card .sales-performance-cny-tag {
  font-size: 9px;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profit-ad-vat-tag,
.profit-th-note {
  font-style: normal;
  font-weight: 600;
  font-size: 10px;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.profit-th-note {
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  margin-top: 3px;
  font-weight: 600;
  line-height: 1.2;
}

.profit-ad-est-tag {
  font-style: normal;
  font-weight: 600;
  font-size: 10px;
  color: #9a3412;
  background: #ffedd5;
  padding: 0 4px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

.profit-summary-card .profit-ad-est-tag {
  font-size: 11px;
  padding: 1px 5px;
}

.profit-ad-api.is-estimated,
.profit-formula-hotspot.is-estimated {
  color: #9a3412;
}

.profit-table thead th[data-profit-col="ad"] {
  white-space: normal;
}

.profit-table thead th[data-profit-col="ad"] .listings-sort-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.25;
}

.profit-ad-cell {
  display: grid;
  gap: 2px;
  justify-items: end;
}

.profit-ad-share {
  font-size: 11px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.profit-summary-card strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profit-metric-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
}

.profit-metric-compare {
  flex: 0 0 auto;
  line-height: 1.2;
  white-space: nowrap;
}

.profit-summary-metric {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.profit-summary-metric > strong {
  flex: 1 1 auto;
  min-width: 0;
}

.profit-summary-metric .profit-metric-compare {
  display: inline-flex;
  flex: 0 0 auto;
}

.profit-summary-metric .sales-performance-compare {
  font-size: 10px;
}

.profit-summary-value {
  display: grid;
  gap: 4px;
  font-weight: 700;
  white-space: nowrap;
}

.profit-summary-cny {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

#profit-analysis .content-grid {
  gap: 10px;
  align-items: stretch;
  height: calc(100vh - 118px);
}

#profit-analysis .surface.span-12 {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 10px 10px 6px;
  overflow: hidden;
}

#profit-analysis .section-heading {
  position: relative;
  z-index: 8;
  flex-shrink: 0;
  margin: 4px 0 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.9));
  backdrop-filter: blur(10px);
  border: 1px solid #e5eaf2;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

#profit-analysis .profit-meta,
#profit-analysis .profit-summary-grid,
#profit-analysis .listings-state {
  flex-shrink: 0;
}

.profit-table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#profit-analysis .listings-pager {
  flex-shrink: 0;
  margin-top: 4px;
  background: #fff;
}

.profit-table {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

.profit-table th,
.profit-table td {
  overflow: visible;
}

.profit-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  overflow: visible;
  text-overflow: clip;
  text-align: center;
  white-space: nowrap;
  background: #f8fbff;
  box-shadow: inset 0 -1px 0 #e6edf6;
}

.profit-table thead th.listings-th-product,
.profit-table .profit-product-td {
  text-align: left;
}

.profit-table thead th[data-profit-col] {
  padding-right: 10px;
}

.profit-col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  z-index: 4;
}

.profit-col-resize::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  right: 4px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.15s ease;
}

.profit-col-resize:hover::after,
body.profit-columns-resizing .profit-col-resize::after {
  background: #94a3b8;
}

body.profit-columns-resizing {
  cursor: col-resize;
  user-select: none;
}

body.profit-columns-resizing .profit-table-wrap {
  cursor: col-resize;
}

.profit-table .profit-product-td,
.profit-table .listings-th-product {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 #e8eef4;
  overflow: hidden;
}

.profit-table thead .listings-th-product {
  top: 0;
  z-index: 5;
  background: #f8fbff;
}

.profit-table .profit-sticky-right {
  position: sticky;
  z-index: 2;
  background: #fff;
}

.profit-table thead th.profit-sticky-right {
  top: 0;
  z-index: 4;
  background: #f8fbff;
}

.profit-table .profit-sticky-right.is-sticky-right-edge {
  box-shadow: -1px 0 0 #e8eef4;
}

.profit-product-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.profit-product-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.profit-product-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: #0f172a;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profit-product-meta {
  font-size: 11px;
  line-height: 1.35;
  color: #64748b;
  word-break: break-all;
}

.profit-value {
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.profit-value.is-simulated {
  color: #64748b;
}

.profit-table .listings-th-num,
.profit-table .listings-td-num {
  text-align: center;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.profit-table .listings-td-num.has-cell-stack {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  vertical-align: middle;
}

.profit-cell-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1.3;
  text-align: center;
}

.profit-cell-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.profit-table .listings-td-num .profit-value,
.profit-table .listings-td-num .profit-edit-cell,
.profit-table .listings-td-num .profit-ad-api,
.profit-table .listings-td-num .profit-ad-pending {
  display: inline-block;
  max-width: 100%;
}

.profit-table .listings-td-num .profit-edit-cell {
  margin: 0 auto;
}

.profit-table .listings-th-action,
.profit-table .listing-actions {
  text-align: center;
  white-space: nowrap;
}

.profit-edit-cell {
  min-width: 48px;
  padding: 2px 6px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.profit-edit-cell.is-empty {
  color: #94a3b8;
  font-weight: 500;
  border-style: dotted;
  background: #f8fafc;
}

.profit-edit-cell.is-simulated {
  border-style: dotted;
  color: #64748b;
}

.profit-edit-cell:hover {
  border-color: #94a3b8;
  background: #fff;
}

.profit-edit-input {
  width: 72px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}

.profit-range-segmented {
  margin-left: auto;
}

.profit-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  white-space: nowrap;
}

.profit-variation-row td:first-child {
  padding-left: 28px;
}

.profit-variation-row .listing-cell-copy strong {
  font-weight: 500;
  font-size: 12.5px;
}

.profit-expand-btn {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent, #2563eb);
  font-size: 11px;
  cursor: pointer;
}

.profit-expand-btn:hover {
  text-decoration: underline;
}

.profit-ad-api {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted, #6b7280);
  font-size: 11px;
}

.profit-order-payment,
.profit-order-gs,
.profit-order-billing {
  margin-top: 2px;
  font-size: 10.5px;
  color: #64748b;
}

.profit-order-pack {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 6px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 10px;
}

.profit-order-kind {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  font-size: 10px;
  font-weight: 700;
}

.profit-order-refund td {
  background: rgba(254, 242, 242, 0.45);
}

.profit-orders-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #64748b;
}

.profit-orders-drawer {
  --profit-orders-drawer-width: 760px;
  grid-template-columns: 1fr min(var(--profit-orders-drawer-width), 95vw);
}

.profit-orders-drawer .listing-detail-panel {
  position: relative;
  min-width: 480px;
}

.profit-orders-drawer .listing-detail-head h3 {
  max-width: none;
}

.profit-orders-drawer .listing-detail-body {
  overflow: auto;
}

.profit-orders-drawer-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  margin-left: -4px;
  cursor: ew-resize;
  z-index: 3;
  touch-action: none;
}

.profit-orders-drawer-resize::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s ease;
}

.profit-orders-drawer-resize:hover::after,
.profit-orders-drawer.is-resizing .profit-orders-drawer-resize::after {
  background: rgba(79, 70, 229, 0.45);
}

body.profit-orders-drawer-resizing {
  cursor: ew-resize;
  user-select: none;
}

body.profit-orders-drawer-resizing .profit-orders-drawer-resize {
  cursor: ew-resize;
}

#profit-analysis.is-refreshing .profit-meta::after {
  content: " · 更新中…";
  color: var(--text-muted, #6b7280);
}

.profit-formula-hotspot {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 8px;
  cursor: help;
  outline: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.profit-formula-hotspot .profit-ad-est-tag {
  align-self: center;
}

.profit-formula-hotspot:hover,
.profit-formula-hotspot:focus-visible {
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.profit-formula-popover {
  position: fixed;
  z-index: 14000;
  width: min(340px, calc(100vw - 24px));
  pointer-events: none;
  filter: drop-shadow(0 18px 40px rgba(15, 23, 42, 0.18));
}

.profit-formula-popover[hidden] {
  display: none !important;
}

.profit-formula-card {
  position: relative;
  padding: 12px 14px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  color: #0f172a;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}

.profit-formula-card::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  transform: translateX(-50%) rotate(45deg);
}

.profit-formula-popover[data-placement="above"] .profit-formula-card::after {
  bottom: -5px;
}

.profit-formula-popover[data-placement="below"] .profit-formula-card::after {
  top: -5px;
  border: 1px solid #e2e8f0;
  border-right: 0;
  border-bottom: 0;
  background: #fff;
}

.profit-formula-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.profit-formula-head strong {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.profit-formula-head span {
  font-size: 11px;
  line-height: 1.45;
  color: #64748b;
}

.profit-formula-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profit-formula-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.profit-formula-op {
  width: 16px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
}

.profit-formula-row.is-minus .profit-formula-op {
  color: #dc2626;
}

.profit-formula-row.is-result {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
}

.profit-formula-row.is-result .profit-formula-op {
  color: #2563eb;
}

.profit-formula-row.is-result .profit-formula-label {
  font-weight: 700;
  color: #0f172a;
}

.profit-formula-row.is-result .profit-formula-value {
  font-size: 13px;
  font-weight: 800;
  color: #1d4ed8;
}

.profit-formula-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profit-formula-label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  line-height: 1.3;
}

.profit-formula-note {
  font-size: 10.5px;
  line-height: 1.35;
  color: #94a3b8;
}

.profit-formula-value {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  white-space: nowrap;
  padding-top: 1px;
}

.profit-formula-footnote {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  font-size: 10.5px;
  line-height: 1.45;
  color: #64748b;
}

/* —— 作图工作台 Studio —— */
.studio-shell {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 16px;
  height: calc(100dvh - 148px);
  max-height: calc(100dvh - 148px);
  min-height: 360px;
  align-items: stretch;
  overflow: hidden;
}

.studio-config,
.studio-results {
  padding: 0;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(232, 241, 255, 0.55) 0%, transparent 120px),
    var(--bg-elevated);
}

.studio-config {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 18px 22px;
  -webkit-overflow-scrolling: touch;
}

.studio-config-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 2px;
}

.studio-config-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.studio-config-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.studio-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.studio-field.grow {
  flex: 1;
  min-width: 0;
}

.studio-field input,
.studio-field textarea,
.studio-field select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.studio-field input:focus,
.studio-field textarea:focus,
.studio-field select:focus {
  outline: none;
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px var(--ml-blue-soft);
}

.studio-field textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}

.studio-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.studio-upload {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px;
  border: 1.5px dashed #b6c7e3;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(52, 131, 250, 0.06), rgba(255, 230, 0, 0.08)),
    #f8fbff;
  cursor: pointer;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.studio-upload strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.studio-upload.dragover,
.studio-upload:hover {
  border-color: var(--ml-blue);
  background:
    linear-gradient(145deg, rgba(52, 131, 250, 0.1), rgba(255, 230, 0, 0.12)),
    #f0f7ff;
  transform: translateY(-1px);
}

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

.studio-thumb {
  position: relative;
  margin: 0;
  width: 76px;
  height: 76px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--line-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.studio-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.studio-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

.studio-empty-thumbs {
  margin: 0;
  font-size: 12px;
  color: #94a3b8;
}

.studio-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.studio-counts label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-weight: 600;
}

.studio-counts input {
  width: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
}

.studio-link-row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.studio-cost-line {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--ml-blue-soft);
  color: #1d4ed8;
  font-size: 12.5px;
  font-weight: 700;
}

.studio-run-btn {
  width: 100%;
  margin-top: 4px;
  min-height: 46px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.studio-parsed-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--line-soft);
}

.studio-parsed-meta strong {
  color: var(--ink);
  font-size: 13.5px;
}

.studio-parse-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.studio-parse-item {
  position: relative;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line-soft);
  aspect-ratio: 1;
  box-shadow: var(--shadow-sm);
}

.studio-parse-item.selected {
  border-color: var(--ml-blue);
  box-shadow: 0 0 0 3px var(--ml-blue-soft);
}

.studio-parse-check {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: rgba(15, 23, 42, 0.35);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}

.studio-parse-item.selected .studio-parse-check {
  background: var(--ml-blue);
  border-color: #fff;
}

.studio-parse-check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
}

.studio-parse-item.selected .studio-parse-check::after {
  opacity: 1;
}

.studio-parse-preview {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.studio-parse-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.studio-parse-item img.is-broken {
  opacity: 0.35;
  object-fit: contain;
  padding: 18%;
}

.studio-results {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.studio-results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.65));
  flex-shrink: 0;
}

.studio-results-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.studio-results-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.studio-fal-status {
  margin-top: 6px !important;
  font-size: 12px !important;
  color: var(--muted) !important;
}

.studio-history {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 22px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.studio-history-empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  border: 1px dashed #c9d6ea;
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(52, 131, 250, 0.05), transparent 55%),
    #f8fbff;
}

.studio-history-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 15px;
}

.studio-history-empty p {
  margin: 0 auto;
  max-width: 360px;
  line-height: 1.5;
}

.studio-history-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.studio-history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: linear-gradient(180deg, #f8fafc, #fff);
  border-bottom: 1px solid var(--line-soft);
}

.studio-history-title strong {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.studio-history-item time {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 3px;
  font-weight: 500;
}

.studio-history-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.studio-cost-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ml-blue-soft);
  color: #1d4ed8;
}

.studio-status-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
}

.studio-status-badge.running {
  background: var(--warn-soft);
  color: #c2410c;
}

.studio-status-badge.failed {
  background: var(--danger-soft);
  color: #b91c1c;
}

.studio-status-badge.ok {
  background: var(--green-soft);
  color: #047857;
}

.studio-history-item.is-running {
  border-color: #fdba74;
  box-shadow: 0 0 0 3px rgba(253, 186, 116, 0.2);
}

.studio-history-running {
  margin: 14px 16px;
  padding: 16px;
  font-size: 13px;
  color: #9a3412;
  background: var(--warn-soft);
  border-radius: var(--radius-sm);
}

.studio-history-message {
  margin: 0 16px 14px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.studio-history-context {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 4px;
}

.studio-history-refs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.studio-history-ref {
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line-soft);
  cursor: zoom-in;
  transition: transform var(--transition), box-shadow var(--transition);
}

.studio-history-ref:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.studio-history-ref img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.studio-history-link,
.studio-history-link-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}

.studio-history-link-label {
  color: var(--ink-secondary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.studio-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--ink-secondary);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
}

.studio-history-prompt {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid var(--line-soft);
}

.studio-history-prompt span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

.studio-history-prompt p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 7.5em;
  overflow: auto;
}

.studio-history-prompt.is-style {
  background: #fffbeb;
  border-color: #fde68a;
}

.studio-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  padding: 12px 16px 16px;
}

.studio-result-card {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.studio-result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.studio-result-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.studio-result-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--line-soft);
}

.studio-result-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition);
  pointer-events: none;
}

.studio-result-thumb:hover .studio-result-zoom,
.studio-result-thumb:focus-visible .studio-result-zoom {
  opacity: 1;
  transform: translateY(0);
}

.studio-result-card figcaption,
.studio-result-card a,
.studio-result-card p {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--ink-secondary);
  font-weight: 600;
}

.studio-result-card a {
  color: var(--brand);
  text-decoration: none;
  border-top: 1px solid var(--line-soft);
}

.studio-result-card.failed {
  min-height: 160px;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #b91c1c;
  background: var(--danger-soft);
  padding: 12px;
}

@media (max-width: 1100px) {
  .studio-shell {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .studio-config,
  .studio-results {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .studio-history {
    overflow: visible;
    flex: none;
    min-height: auto;
  }
}
