:root {
  --bg: #eef2f7;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --sidebar: linear-gradient(180deg, #20324d 0%, #1c2637 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --text: #18212f;
  --muted: #6b7280;
  --line: rgba(148, 163, 184, 0.22);
  --blue: #2684ff;
  --blue-deep: #0f5ed7;
  --teal: #10b7a5;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --app-shell-padding: 20px;
  --app-shell-gap: 24px;
  --sidebar-width: 260px;
  --panel-padding: 24px;
  --table-font-size: 0.94rem;
  --table-cell-padding-y: 14px;
  --table-cell-padding-x: 16px;
  --table-min-width: 1280px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(38, 132, 255, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(16, 183, 165, 0.16), transparent 22%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  gap: var(--app-shell-gap);
  padding: var(--app-shell-padding);
}

html[data-host-mode="cloud"][data-auth-state="locked"] .app-shell {
  display: none;
}

.sidebar {
  background: var(--sidebar);
  color: #e8eefc;
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  position: sticky;
  top: var(--app-shell-padding);
  height: calc(100vh - (var(--app-shell-padding) * 2));
  overflow: hidden;
  border: 1px solid var(--sidebar-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
}

.brand p,
.sidebar-footer p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.brand p {
  color: rgba(232, 238, 252, 0.66);
}

.nav-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.nav-group-secondary {
  margin-top: 24px;
  padding-top: clamp(20px, 4vh, 40px);
  padding-bottom: clamp(8px, 2vh, 20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
  border: 0;
  background: transparent;
  color: rgba(232, 238, 252, 0.82);
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item-secondary {
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: 12px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sidebar-footer strong {
  display: block;
  margin-top: 4px;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.app-booting .app-shell {
  opacity: 0;
  visibility: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 22px 24px;
  border-radius: calc(var(--radius-lg) + 2px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72));
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(16px);
}

.topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(720px, 100%);
}

.topbar-release {
  margin: 12px 0 0;
  font-size: 0.95rem;
  line-height: 1.35;
  color: #64748b;
}

.topbar h1,
.panel h2,
.panel-highlight h2 {
  margin: 6px 0 0;
  font-size: 1.9rem;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  max-width: 440px;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.language-switch span {
  font-size: 0.9rem;
  color: var(--muted);
}

.language-switch select {
  width: auto;
  min-width: 98px;
  padding: 8px 12px;
  border-radius: 999px;
  background: white;
}

.chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: #d9ecff;
  color: #0a57ca;
  font-size: 0.9rem;
}

.chip.ghost {
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
}

#sync-status {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  white-space: normal;
  line-height: 1.35;
  border-radius: 22px;
}

#sync-status .sync-status-title {
  font-size: 0.96rem;
  font-weight: 600;
}

#sync-status .sync-status-line {
  font-size: 0.82rem;
  color: var(--muted);
}

.log-detail {
  max-width: 320px;
  line-height: 1.5;
  white-space: normal;
}

.log-target {
  color: #4b5563;
}

.log-path {
  display: inline-block;
  margin-top: 4px;
  color: #94a3b8;
  font-size: 12px;
}

.chip.need {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.user-indicator {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.user-indicator span {
  font-size: 0.84rem;
  color: var(--muted);
}

.user-indicator strong {
  font-size: 0.96rem;
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view.active.dashboard-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.stat-card,
.panel,
.panel-highlight {
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.stat-card {
  position: relative;
  min-height: 0;
  padding: 16px 18px 14px;
  overflow: hidden;
}

.stat-card h3,
.analysis-grid h3 {
  margin: 0 0 4px;
  font-size: 0.94rem;
}

.stat-card strong {
  font-size: 1.7rem;
  line-height: 1;
}

.stat-card p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: none;
  line-height: 1.35;
  font-size: 0.92rem;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, rgba(38, 132, 255, 0.9), rgba(16, 183, 165, 0.9));
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -34px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(38, 132, 255, 0.12), transparent 68%);
  pointer-events: none;
}

.stat-card-primary::before,
.stat-card-secondary::before {
  background: linear-gradient(90deg, rgba(16, 183, 165, 0.9), rgba(38, 132, 255, 0.72));
}

.stat-card-primary {
  background:
    radial-gradient(circle at top right, rgba(38, 132, 255, 0.14), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 255, 0.86));
}

.stat-card-tertiary::before {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.88), rgba(59, 130, 246, 0.72));
}

.stat-card-quaternary::before {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.88), rgba(99, 102, 241, 0.72));
}

.stat-card-secondary,
.stat-card-quaternary {
  background:
    radial-gradient(circle at top right, rgba(16, 183, 165, 0.1), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(245, 250, 249, 0.84));
}

.stat-card-tertiary {
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.12), transparent 34%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(244, 249, 255, 0.86));
}

.panel,
.panel-highlight {
  padding: var(--panel-padding);
}

.panel-highlight {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  min-height: 220px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(38, 132, 255, 0.12), rgba(16, 183, 165, 0.08)),
    var(--panel-strong);
}

.panel-highlight-copy {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.panel-highlight-text {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 0;
  line-height: 1.75;
  color: #42526b;
  justify-self: end;
}

.panel-highlight-orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 240px;
  height: 240px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.8;
}

.panel-highlight-orbit span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(38, 132, 255, 0.16);
}

.panel-highlight-orbit span:nth-child(2) {
  inset: 24px;
  border-color: rgba(16, 183, 165, 0.18);
}

.panel-highlight-orbit span:nth-child(3) {
  inset: 58px;
  background: radial-gradient(circle, rgba(38, 132, 255, 0.18), rgba(16, 183, 165, 0.08) 58%, transparent 62%);
  border: 0;
}

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

.table-count {
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 120px;
  gap: 12px;
  margin-bottom: 14px;
}

.filters-wide {
  grid-template-columns: minmax(260px, 1fr) 180px 180px 120px;
}

.filters-new-listing {
  grid-template-columns: minmax(320px, 1fr) 148px 96px 120px;
  align-items: center;
}

.filters-new-listing #new-listing-open,
.filters-new-listing #new-listing-search {
  width: 100%;
  min-width: 0;
}

.clearance-filters {
  grid-template-columns: minmax(320px, 1fr) 120px;
}

.clearance-actions {
  display: flex;
  gap: 12px;
}

.clearance-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

.clearance-inline-actions button {
  min-width: 120px;
  flex: 0 0 auto;
}

.clearance-filters-bar {
  grid-template-columns: minmax(320px, 1fr) auto;
  align-items: center;
}

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

.clearance-history-pager {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid var(--line);
  color: var(--muted);
}

.clearance-history-pager select {
  min-width: 180px;
  width: auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: white;
}

.clearance-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.clearance-card {
  min-height: 120px;
}

.stale-toolbar {
  align-items: center;
}

.stale-filters {
  grid-template-columns: minmax(260px, 1.6fr) repeat(3, minmax(140px, 0.7fr)) auto;
}

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

.stale-flow-card {
  position: relative;
  min-height: 186px;
  padding: 20px 18px 18px;
  border-radius: 22px;
  border: 1px solid rgba(191, 219, 254, 0.75);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(239, 246, 255, 0.92) 100%);
  box-shadow: 0 18px 42px rgba(148, 163, 184, 0.14);
}

.stale-flow-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.stale-flow-card h3 {
  margin: 14px 0 10px;
  font-size: 1.08rem;
}

.stale-flow-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.stale-flow-card strong {
  display: block;
  margin-top: 14px;
  color: var(--text);
  line-height: 1.5;
  font-size: 0.9rem;
}

.stale-summary-grid {
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.stale-summary-card {
  min-height: 132px;
}

.stale-summary-card p {
  font-size: 0.84rem;
  line-height: 1.45;
}

.stale-inventory-table {
  table-layout: fixed;
}

.stale-inventory-table th,
.stale-inventory-table td {
  padding: 12px 10px;
  vertical-align: top;
}

.stale-inventory-table th:nth-child(1),
.stale-inventory-table td:nth-child(1) {
  width: 132px;
}

.stale-inventory-table th:nth-child(2),
.stale-inventory-table td:nth-child(2) {
  width: 110px;
}

.stale-inventory-table th:nth-child(3),
.stale-inventory-table td:nth-child(3) {
  width: 130px;
}

.stale-inventory-table th:nth-child(4),
.stale-inventory-table td:nth-child(4) {
  width: 260px;
}

.stale-inventory-table th:nth-child(5),
.stale-inventory-table td:nth-child(5) {
  width: 150px;
}

.stale-inventory-table th:nth-child(n + 6):nth-child(-n + 10),
.stale-inventory-table td:nth-child(n + 6):nth-child(-n + 10) {
  width: 92px;
  text-align: center;
}

.stale-inventory-table th:nth-child(11),
.stale-inventory-table td:nth-child(11) {
  width: 148px;
}

.stale-inventory-table th:nth-child(12),
.stale-inventory-table td:nth-child(12) {
  width: 148px;
}

.stale-inventory-table th:nth-child(13),
.stale-inventory-table td:nth-child(13) {
  width: 148px;
}

.stale-inventory-table th:nth-child(14),
.stale-inventory-table td:nth-child(14) {
  width: 118px;
}

.stale-inventory-table th:nth-child(15),
.stale-inventory-table td:nth-child(15) {
  width: 188px;
}

.stale-inventory-table th:nth-child(16),
.stale-inventory-table td:nth-child(16) {
  width: 220px;
}

.stale-inventory-table th:nth-child(17),
.stale-inventory-table td:nth-child(17) {
  width: 152px;
}

.stale-inline-select,
.stale-note-input {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font: inherit;
}

.stale-inline-select {
  padding: 10px 12px;
}

.stale-note-input {
  padding: 10px 12px;
}

.stale-number-cell {
  text-align: center;
}

.stale-action-cell,
.stale-next-cell {
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

.row-selected {
  background: rgba(38, 132, 255, 0.08);
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

button {
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
  color: white;
  cursor: pointer;
  padding: 13px 18px;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.16);
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.panel-sub {
  padding: 18px;
}

.purchase-plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.purchase-data-table {
  table-layout: fixed;
}

.purchase-data-table th,
.purchase-data-table td {
  padding: 12px 10px;
}

.purchase-data-table th:nth-child(1),
.purchase-data-table td:nth-child(1) {
  width: 58px;
}

.purchase-data-table th:nth-child(2),
.purchase-data-table td:nth-child(2) {
  width: 132px;
}

.purchase-data-table th:nth-child(3),
.purchase-data-table td:nth-child(3) {
  width: 150px;
}

.purchase-data-table th:nth-child(n + 4):nth-child(-n + 7),
.purchase-data-table td:nth-child(n + 4):nth-child(-n + 7) {
  width: 52px;
  text-align: center;
}

.purchase-data-table th:nth-child(8),
.purchase-data-table td:nth-child(8) {
  width: 82px;
}

.purchase-data-table th:nth-child(9),
.purchase-data-table td:nth-child(9) {
  width: 156px;
}

.purchase-data-table th:nth-child(10),
.purchase-data-table td:nth-child(10) {
  width: 176px;
}

.purchase-data-table th:nth-child(11),
.purchase-data-table td:nth-child(11) {
  width: 86px;
}

.purchase-data-table th:nth-child(12),
.purchase-data-table td:nth-child(12) {
  width: 188px;
}

.purchase-data-table th:nth-child(n + 13):nth-child(-n + 16),
.purchase-data-table td:nth-child(n + 13):nth-child(-n + 16) {
  width: 78px;
  text-align: center;
}

.purchase-data-table th:nth-child(17),
.purchase-data-table td:nth-child(17) {
  width: 300px;
}

.purchase-plan-table th:nth-child(18),
.purchase-plan-table td:nth-child(18) {
  width: 90px;
  text-align: center;
}

.th-two-line {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.15;
}

.purchase-supplier-cell,
.purchase-warehouse-cell {
  word-break: break-word;
  line-height: 1.45;
}

.purchase-warehouse-cell {
  white-space: nowrap;
  word-break: normal;
}

.purchase-ref-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.purchase-ref-line {
  white-space: nowrap;
  line-height: 1.35;
}

.purchase-plan-stats {
  margin-bottom: 18px;
}

.purchase-plan-stats .stat-card strong {
  font-size: 1.55rem;
}

.purchase-plan-stats .stat-card p {
  font-size: 0.88rem;
}

.purchase-plan-panel {
  border: 1px solid var(--line);
}

.purchase-plan-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.purchase-plan-history-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.purchase-plan-toolbar {
  align-items: flex-start;
  gap: 16px 18px;
}

.purchase-plan-actions {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 12px;
  align-items: center;
  justify-content: end;
}

.purchase-plan-button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.purchase-plan-button-row button {
  min-width: 92px;
}

.purchase-plan-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.purchase-plan-inline-actions button {
  min-width: 104px;
  flex: 0 0 auto;
}

.purchase-plan-filters {
  grid-template-columns: minmax(320px, 1fr) auto;
  align-items: center;
}

.purchase-plan-history-pager select {
  min-width: 0;
}

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

.section-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.user-switcher {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.user-current-panel {
  max-width: 680px;
  margin-bottom: 18px;
}

.user-inline-row {
  background: rgba(59, 130, 246, 0.04);
}

.user-inline-input {
  width: 100%;
  min-width: 120px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.user-inline-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

.purchase-plan-empty {
  margin-top: 18px;
  padding: 36px 28px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 24px;
  color: var(--muted);
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.purchase-plan-collapse-head {
  align-items: center;
}

.purchase-plan-collapse-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-toggle {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.collapse-toggle:hover {
  background: rgba(59, 130, 246, 0.08);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-pill.status-attention {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.status-pill.status-normal {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.status-pill.status-secondary {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.status-pill.status-muted {
  background: rgba(148, 163, 184, 0.14);
  color: #475569;
}

.purchase-qty-positive {
  color: #b91c1c;
  font-weight: 700;
}

.purchase-qty-muted {
  color: #475569;
}

.purchase-qty-tooltip-target {
  cursor: help;
}

.hover-tooltip {
  position: absolute;
  z-index: 9999;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  white-space: normal;
}

.hover-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.btn-light.disabled,
.btn-green.disabled,
.btn-blue.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-disabled,
input.input-disabled:disabled {
  background: rgba(248, 250, 252, 0.55);
  color: #a0aec0;
  cursor: not-allowed;
}

.new-listing-table-wrap table {
  min-width: 1680px;
}

[data-view-panel="new-listing"] thead th:nth-child(2),
[data-view-panel="new-listing"] tbody td:nth-child(2) {
  width: 84px;
}

[data-view-panel="new-listing"] thead th:nth-child(3),
[data-view-panel="new-listing"] tbody td:nth-child(3) {
  width: 134px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: var(--table-min-width);
  background: rgba(255, 255, 255, 0.86);
}

[data-view-panel="sku"] .table-wrap table {
  table-layout: fixed;
}

[data-view-panel="sku"] thead th,
[data-view-panel="sku"] tbody td {
  padding: 12px 10px;
  vertical-align: top;
}

[data-view-panel="sku"] thead th:nth-child(1),
[data-view-panel="sku"] tbody td:nth-child(1) {
  width: 56px;
}

[data-view-panel="sku"] thead th:nth-child(2),
[data-view-panel="sku"] tbody td:nth-child(2) {
  width: 58px;
}

[data-view-panel="sku"] thead th:nth-child(3),
[data-view-panel="sku"] tbody td:nth-child(3) {
  width: 132px;
}

[data-view-panel="sku"] thead th:nth-child(4),
[data-view-panel="sku"] tbody td:nth-child(4) {
  width: 156px;
}

[data-view-panel="sku"] thead th:nth-child(5),
[data-view-panel="sku"] tbody td:nth-child(5) {
  width: 190px;
}

[data-view-panel="sku"] thead th:nth-child(6),
[data-view-panel="sku"] tbody td:nth-child(6) {
  width: 60px;
  text-align: center;
}

[data-view-panel="sku"] thead th:nth-child(n + 7):nth-child(-n + 13),
[data-view-panel="sku"] tbody td:nth-child(n + 7):nth-child(-n + 13) {
  width: 56px;
  text-align: center;
}

[data-view-panel="sku"] thead th:nth-child(8),
[data-view-panel="sku"] tbody td:nth-child(8) {
  width: 72px;
}

[data-view-panel="sku"] thead th:nth-child(13),
[data-view-panel="sku"] tbody td:nth-child(13) {
  width: 66px;
}

[data-view-panel="sku"] thead th:nth-child(14),
[data-view-panel="sku"] tbody td:nth-child(14) {
  width: 126px;
}

[data-view-panel="sku"] thead th:nth-child(15),
[data-view-panel="sku"] tbody td:nth-child(15) {
  width: 78px;
  text-align: center;
}

[data-view-panel="sku"] thead th:nth-child(16),
[data-view-panel="sku"] tbody td:nth-child(16) {
  width: 220px;
}

[data-view-panel="sku"] thead th:nth-child(17),
[data-view-panel="sku"] tbody td:nth-child(17) {
  width: 142px;
}

[data-view-panel="sku"] thead th:nth-child(18),
[data-view-panel="sku"] tbody td:nth-child(18) {
  width: 74px;
  text-align: center;
}

.mabang-po-table {
  table-layout: fixed;
}

.mabang-po-table .col-purchase-date {
  width: 9%;
}

.mabang-po-table .col-purchase-no {
  width: 12%;
}

.mabang-po-table .col-sku {
  width: 12%;
}

.mabang-po-table .col-total-price {
  width: 8%;
}

.mabang-po-table .col-total-qty {
  width: 7%;
}

.mabang-po-table .col-warehouse-bin {
  width: 10%;
}

.mabang-po-table .col-shipping-method {
  width: 8%;
}

.mabang-po-table .col-tracking-no {
  width: 12%;
}

.mabang-po-table .col-remark {
  width: 14%;
}

.mabang-po-table .col-action {
  width: 92px;
}

th,
td {
  padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: var(--table-font-size);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(248, 250, 252, 0.94);
}

.table-wrap thead th {
  background: rgba(248, 250, 252, 0.98);
  box-shadow: inset 0 -1px 0 var(--line);
}

.floating-table-head {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  background: rgba(248, 250, 252, 0.98);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.floating-table-head.visible {
  display: block;
}

.floating-table-head table {
  margin: 0;
  background: transparent;
}

.floating-table-head th {
  background: rgba(248, 250, 252, 0.98);
}

.sortable-th {
  padding-top: 8px;
  padding-bottom: 8px;
}

.sort-header-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  transform: none;
  font: inherit;
  text-align: left;
}

.sort-header-button:hover {
  box-shadow: none;
  transform: none;
}

.sort-header-label {
  display: inline-flex;
  align-items: center;
}

.sort-arrows {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.sort-arrow {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  opacity: 0.35;
}

.sort-arrow.up {
  border-bottom: 7px solid #60a5fa;
}

.sort-arrow.down {
  border-top: 7px solid #60a5fa;
}

.sort-arrow.active {
  opacity: 1;
}

.mabang-po-table th,
.mabang-po-table td {
  padding: 13px 14px;
  line-height: 1.45;
  word-break: break-word;
}

tbody tr:hover {
  background: rgba(38, 132, 255, 0.04);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(16, 183, 165, 0.1);
  color: #0b8f81;
}

.badge.warn {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

.badge.clearance {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.badge-amazon {
  min-width: 32px;
  justify-content: center;
  font-weight: 700;
  padding: 4px 8px;
}

.badge-normal-short {
  background: rgba(16, 185, 129, 0.12);
  color: #0f9f6e;
}

.badge-clearance-short {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.badge-stop-short {
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
}

.product-thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(38, 132, 255, 0.14), rgba(16, 183, 165, 0.14));
  color: #0f5ed7;
  font-size: 0.82rem;
  font-weight: 700;
}

.amazon-title-cell {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  min-width: 220px;
  max-width: 320px;
  min-height: 2.9em;
  white-space: normal;
  word-break: break-word;
}

.sku-cn-cell,
.sku-en-cell {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.42;
  white-space: normal;
  word-break: break-word;
}

.sku-cn-cell {
  -webkit-line-clamp: 2;
  min-width: 0;
  max-width: 100%;
}

.sku-en-cell {
  -webkit-line-clamp: 2;
  min-width: 0;
  max-width: 100%;
}

.purchase-sku-cell {
  min-width: 120px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.purchase-note-cell {
  min-width: 180px;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sku-package-select {
  min-width: 0;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
}

.sku-package-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.sku-package-reason {
  max-width: 240px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: normal;
}

.api-review-header-note {
  margin-top: 6px;
  font-size: 0.74rem;
  line-height: 1.35;
  color: #c2410c;
  font-weight: 600;
  white-space: normal;
}

.api-review-cell-group {
  margin-top: 6px;
}

.api-review-row-note {
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: normal;
}

.btn-add {
  min-width: 110px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #f0fdf4;
}

.btn-add:hover {
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.2);
}

.row-expand {
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.batch-actions button {
  border: none;
  cursor: pointer;
  font: inherit;
}

.mini-action {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
}

.mini-action.danger {
  background: #ef6464;
}

.new-listing-status-select {
  min-width: 86px;
  min-height: 34px;
  padding: 0 30px 0 12px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.1;
  vertical-align: middle;
  background-position: calc(100% - 15px) calc(50% - 3px), calc(100% - 10px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
}

[data-view-panel="new-listing"] tbody td {
  vertical-align: middle;
}

.new-listing-sub-row td {
  background: rgba(38, 132, 255, 0.04);
}

.new-listing-sub-head td {
  background: rgba(15, 23, 42, 0.06);
  color: #64748b;
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.modal-shell.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.modal-card {
  position: relative;
  width: min(1560px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 20px auto;
  padding: 28px;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-card-xl {
  width: min(1600px, calc(100vw - 40px));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.auth-login-card {
  width: min(440px, calc(100vw - 32px));
  margin-top: max(80px, 14vh);
  padding: 32px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background:
    radial-gradient(circle at top right, rgba(38, 132, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94));
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.16);
  animation: auth-card-enter 180ms ease-out;
}

.auth-login-head {
  margin-bottom: 18px;
}

.auth-login-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: rgba(38, 132, 255, 0.1);
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-login-head h2 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.auth-login-head p {
  margin: 0;
  color: var(--muted);
}

.auth-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-login-form input {
  width: 100%;
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 18px;
  font: inherit;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.auth-login-form input:focus {
  outline: none;
  border-color: rgba(38, 132, 255, 0.42);
  box-shadow: 0 0 0 4px rgba(38, 132, 255, 0.12);
  transform: translateY(-1px);
}

.auth-login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(212, 59, 59, 0.08);
  border: 1px solid rgba(212, 59, 59, 0.12);
  color: #d43b3b;
  font-size: 0.95rem;
}

.auth-login-tip {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

#login-submit {
  width: 100%;
  justify-content: center;
}

#login-submit.is-loading {
  opacity: 0.86;
  pointer-events: none;
}

#login-submit.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 10px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: auth-spin 0.75s linear infinite;
}

@keyframes auth-card-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes auth-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.new-listing-form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.new-listing-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.new-listing-field span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.new-listing-field input,
.new-listing-field select {
  width: 100%;
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 18px;
  font: inherit;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  appearance: none;
}

.new-listing-field input:focus,
.new-listing-field select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.new-listing-channel-section {
  margin-top: 8px;
}

.section-head-compact {
  margin-bottom: 10px;
}

.new-listing-channel-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) 140px;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.new-listing-channel-form label,
.new-listing-form-grid label {
  position: relative;
}

.new-listing-form-grid > .new-listing-remark-field {
  grid-column: 1 / span 2;
}

.new-listing-field select {
  padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 22px) calc(50% - 3px), calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.new-listing-field input::placeholder {
  color: #8b95a7;
}

.new-listing-channel-form .btn-blue {
  min-height: 52px;
}

.new-listing-channel-table {
  min-width: 1120px;
}

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

.analysis-grid article {
  padding: 18px;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--line);
}

.hidden {
  display: none;
}

.profit-tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.05);
  overflow: auto;
}

.profit-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 18px;
  border-radius: 12px;
  white-space: nowrap;
}

.profit-tab.active {
  background: white;
  color: var(--blue);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.profit-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.profit-source-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: -4px 0 18px;
}

.profit-source-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.profit-source-chip-highlight {
  color: #9f1239;
  background: #ffe4e6;
  border: 1px solid #fecdd3;
}

.profit-source-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.profit-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.profit-search-bar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 72px;
  gap: 10px;
  width: min(100%, 920px);
  align-items: center;
}

.btn-green {
  background: linear-gradient(135deg, #56c271 0%, #2f9e44 100%);
}

.btn-blue {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
}

.btn-light,
.btn-ghost {
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
}

.advanced-search-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.advanced-search-modal.hidden {
  display: none;
}

.advanced-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(4px);
}

.advanced-search-card {
  position: relative;
  z-index: 1;
  width: min(860px, 100%);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  padding: 24px;
}

.profit-filter-card {
  width: min(980px, 100%);
}

.advanced-search-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.advanced-search-head h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.advanced-search-head p,
.advanced-search-note {
  margin: 0;
  color: var(--muted);
}

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

.advanced-search-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.advanced-search-grid textarea {
  width: 100%;
  min-height: 160px;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  font: inherit;
  resize: vertical;
  background: rgba(248, 250, 252, 0.96);
}

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

.profit-filters label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

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

.profit-filter-range input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font: inherit;
  background: rgba(248, 250, 252, 0.96);
}

.advanced-search-note {
  margin-top: 16px;
}

.advanced-search-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.po-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.po-toolbar-unified {
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.po-unified-search {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 72px;
  gap: 10px;
  width: min(100%, 680px);
}

.narrow-col {
  width: 42px;
}

#mabang-table-wrap thead th,
#freight-table-wrap thead th,
#batch-table-wrap thead th {
  vertical-align: middle;
  white-space: nowrap;
}

#mabang-table-wrap thead th:first-child,
#mabang-table-wrap tbody td:first-child,
#freight-table-wrap thead th:first-child,
#freight-table-wrap tbody td:first-child {
  width: 64px;
  min-width: 64px;
  white-space: nowrap;
}

#batch-table-wrap thead th:nth-child(1),
#batch-table-wrap tbody td:nth-child(1),
#batch-table-wrap thead th:nth-child(2),
#batch-table-wrap tbody td:nth-child(2) {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

#batch-table-wrap thead th:nth-child(3),
#batch-table-wrap tbody td:nth-child(3) {
  width: 220px;
  min-width: 220px;
}

#batch-table-wrap thead th:nth-child(4),
#batch-table-wrap tbody td:nth-child(4) {
  width: 180px;
  min-width: 180px;
}

#batch-table-wrap thead th:nth-child(5),
#batch-table-wrap tbody td:nth-child(5) {
  width: 110px;
  min-width: 110px;
}

#batch-table-wrap thead th:nth-child(6),
#batch-table-wrap tbody td:nth-child(6) {
  width: 180px;
  min-width: 180px;
}

.batch-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: #94a3b8;
  font-size: 1rem;
}

.batch-code-input {
  width: 180px;
  padding: 7px 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #fff;
  border-radius: 4px;
  color: #64748b;
  text-align: left;
}

.batch-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.batch-detail-block td {
  padding: 0;
  background: rgba(248, 250, 252, 0.9);
}

.batch-detail-table-wrap {
  margin: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  background: white;
}

.batch-detail-table {
  min-width: 1400px;
}

.batch-detail-table thead th {
  background: rgba(248, 250, 252, 0.92);
  white-space: nowrap;
  vertical-align: middle;
}

.batch-detail-table tbody td {
  vertical-align: middle;
}

.batch-detail-table thead th:nth-child(1),
.batch-detail-table tbody td:nth-child(1) {
  width: 72px;
  min-width: 72px;
  text-align: center;
}

.batch-detail-table thead th:nth-child(2),
.batch-detail-table tbody td:nth-child(2) {
  width: 136px;
  min-width: 136px;
}

.batch-detail-table thead th:nth-child(3),
.batch-detail-table tbody td:nth-child(3) {
  width: 120px;
  min-width: 120px;
}

.batch-detail-table thead th:nth-child(4),
.batch-detail-table tbody td:nth-child(4) {
  width: 84px;
  min-width: 84px;
}

.batch-detail-table thead th:nth-child(5),
.batch-detail-table tbody td:nth-child(5) {
  width: 152px;
  min-width: 152px;
}

.batch-detail-table thead th:nth-child(6),
.batch-detail-table tbody td:nth-child(6) {
  width: 96px;
  min-width: 96px;
}

.batch-detail-table thead th:nth-child(7),
.batch-detail-table tbody td:nth-child(7) {
  width: 92px;
  min-width: 92px;
}

.batch-detail-table thead th:nth-child(8),
.batch-detail-table tbody td:nth-child(8) {
  width: 124px;
  min-width: 124px;
}

.batch-detail-table thead th:nth-child(9),
.batch-detail-table tbody td:nth-child(9) {
  width: 188px;
  min-width: 188px;
}

.batch-detail-table tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.55);
}

.batch-inline-input {
  width: 100%;
  min-width: 150px;
  padding: 7px 10px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: #fff;
  border-radius: 6px;
  color: #475569;
  font: inherit;
  text-align: left;
}

.batch-inline-input-no {
  min-width: 172px;
  max-width: 188px;
}

.batch-inline-input-remark {
  min-width: 164px;
}

.batch-no-cell {
  width: 176px;
  padding-right: 18px !important;
}

.batch-remark-cell {
  width: 214px;
  padding-right: 18px !important;
}

.batch-status-cell {
  min-width: 108px;
  padding-left: 10px !important;
  padding-right: 12px !important;
  white-space: nowrap;
}

.batch-action-cell {
  min-width: 92px;
  padding-left: 10px !important;
  white-space: nowrap;
}

.batch-inline-input[readonly] {
  cursor: default;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 6px 10px;
  border-radius: 4px;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
}

.mini-tag.blue {
  background: #4a9cff;
}

.mini-tag.green {
  background: #72c645;
}

.mini-tag.orange {
  background: #f2ac2f;
}

.mini-tag.red {
  background: #ff7d7d;
}

.mini-tag.gray {
  background: #9ca3af;
}

.mini-tag.soft-blue {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
}

.mini-tag.blue.soft,
.mini-tag.green.soft,
.mini-tag.orange.soft,
.mini-tag.red.soft,
.mini-tag.gray.soft {
  opacity: 0.45;
}

.mini-tag:disabled {
  cursor: not-allowed;
  pointer-events: none;
}

.action-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 0;
  background: #ff6b6b;
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  word-break: keep-all;
  line-height: 1;
}

.action-tag.action-tag-manual {
  background: #f59e0b;
}

.action-tag.action-tag-auto {
  background: #cbd5e1;
  color: #475569;
}

.action-tag:disabled {
  cursor: not-allowed;
}

.po-row-matched td {
  color: #94a3b8;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.po-row-matched .action-tag {
  opacity: 0.45;
}

.po-empty {
  margin-top: 8px;
}

.profit-bulk {
  margin-top: 6px;
}

.bulk-results-wrap {
  margin-top: 14px;
}

.bulk-results-wrap table {
  table-layout: fixed;
  width: 100%;
}

.bulk-results-wrap thead th {
  vertical-align: middle;
  line-height: 1.2;
}

#profit-table-wrap thead th {
  vertical-align: middle;
  line-height: 1.2;
}

.bulk-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.92);
  padding: 20px;
}

.bulk-card h3 {
  margin: 0 0 8px;
}

.bulk-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.bulk-card textarea {
  width: 100%;
  min-height: 220px;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  font: inherit;
  resize: vertical;
  margin-bottom: 14px;
}

.profit-negative {
  color: #dc2626;
  font-weight: 600;
}

.profit-positive {
  color: #16a34a;
  font-weight: 600;
}

.profit-name-cell {
  max-width: 220px;
  vertical-align: top;
}

.profit-metric-col {
  text-align: center;
  white-space: normal;
}

.profit-metric-col .sort-header-button {
  justify-content: center;
  text-align: center;
}

.profit-metric-col .sort-header-label {
  justify-content: center;
}

.profit-header-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.15;
}

.profit-metric-cell {
  text-align: center;
  white-space: nowrap;
}

.profit-cell-note {
  margin-top: 3px;
  font-size: 0.73rem;
  line-height: 1.1;
  color: #dc2626;
  font-weight: 600;
  white-space: normal;
}

.profit-name-content {
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  min-height: 2.8em;
}

#profit-table-body td.profit-source-highlight {
  background: #fff1f2;
  color: #9f1239;
  box-shadow: inset 0 0 0 1px #fecdd3;
}

.table-inline-input {
  width: 100%;
  min-width: 84px;
  padding: 8px 10px;
  border: 1px solid #d7dfef;
  border-radius: 10px;
  background: #fff;
  color: #1f2937;
  font: inherit;
}

pre {
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  background: #111827;
  color: #e5f0ff;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.integration-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(460px, 1.2fr);
  gap: 20px;
  align-items: start;
}

.integration-config-column,
.integration-output-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.integration-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  min-width: 0;
}

.integration-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0 0;
}

.integration-actions-bottom {
  margin-top: 18px;
}

.integration-subtitle {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.integration-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.integration-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 6px;
  align-items: stretch;
}

.integration-form input,
.integration-query-form input {
  min-width: 0;
}

.integration-query-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0;
}

.integration-single-field {
  grid-template-columns: minmax(0, 1fr);
}

.integration-config-grid {
  margin-bottom: 0;
}

.integration-output-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.integration-output-head h3 {
  margin: 0;
  font-size: 1rem;
}

.integration-output-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

#integration-output {
  min-height: 520px;
  max-height: calc(100vh - 220px);
  font-size: 0.9rem;
  line-height: 1.5;
}

.settings-topbar,
.settings-template-toolbar {
  grid-template-columns: 220px minmax(240px, 1fr) 140px;
}

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

#settings-base-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-field {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.settings-field span {
  flex: 0 0 240px;
  padding: 14px 16px;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.94);
  border-right: 1px solid var(--line);
}

.settings-field span small {
  font-size: 0.82em;
  opacity: 0.75;
}

.settings-field input {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.settings-template-note {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.88);
  color: var(--muted);
}

.settings-package-rule-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.94), rgba(255, 255, 255, 0.96));
}

.settings-package-rule-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.settings-package-rule-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.settings-package-rule-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.settings-package-rule-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(191, 203, 220, 0.9);
  background: rgba(255, 255, 255, 0.92);
}

.settings-package-rule-item strong {
  font-size: 0.95rem;
}

.settings-package-rule-item span {
  color: var(--muted);
  line-height: 1.5;
}

.settings-template-toolbar {
  grid-template-columns: 210px minmax(320px, 1fr) auto auto auto;
  align-items: center;
}

.settings-template-toolbar button {
  width: 120px;
  justify-self: start;
  white-space: nowrap;
}

.settings-template-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-template-table {
  min-width: 1500px;
}

.settings-template-table input,
.settings-template-table select {
  min-width: 86px;
  padding: 8px 10px;
  border-radius: 10px;
}

.settings-template-table .template-readonly-value {
  display: inline-block;
  min-width: 86px;
  padding: 8px 2px;
  color: var(--ink);
  background: transparent;
  border: 0;
  line-height: 1.25;
}

.settings-template-table .template-platform-cell {
  font-weight: 700;
  color: var(--ink);
  min-width: 84px;
}

.settings-template-table .template-select-cell,
.settings-template-table .template-select-head {
  width: 54px;
  min-width: 54px;
  text-align: center;
}

.settings-template-table .template-select-cell input {
  min-width: auto;
  width: 18px;
  height: 18px;
}

.settings-template-table td {
  min-width: 96px;
}

@media (max-width: 1440px) {
  :root {
    --app-shell-padding: 14px;
    --app-shell-gap: 16px;
    --sidebar-width: 214px;
    --panel-padding: 18px;
    --table-font-size: 0.88rem;
    --table-cell-padding-y: 11px;
    --table-cell-padding-x: 10px;
    --table-min-width: 1120px;
  }

  .brand {
    gap: 10px;
    margin-bottom: 20px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .nav-item {
    padding: 12px 13px;
    font-size: 0.95rem;
  }

  .sidebar-footer {
    padding: 14px;
  }

  .topbar {
    padding: 18px 20px;
    gap: 14px;
  }

  .topbar h1,
  .panel h2,
  .panel-highlight h2 {
    font-size: 1.65rem;
  }

  .profit-tab {
    padding: 10px 14px;
  }

  .profit-search-bar {
    width: min(100%, 760px);
    grid-template-columns: minmax(220px, 1fr) 72px;
  }

  .amazon-title-cell {
    min-width: 180px;
    max-width: 240px;
  }

  .sku-cn-cell {
    min-width: 108px;
    max-width: 140px;
  }

  .sku-en-cell {
    min-width: 120px;
    max-width: 170px;
  }

  .profit-name-cell {
    max-width: 170px;
  }

  .new-listing-table-wrap table {
    min-width: 1480px;
  }

  .new-listing-channel-table,
  .batch-detail-table,
  .settings-template-table {
    min-width: 1040px;
  }

  .panel-highlight-orbit {
    width: 208px;
    height: 208px;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    top: auto;
    height: auto;
    padding-bottom: 18px;
  }

  .analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    max-width: none;
    justify-content: flex-start;
  }

  .panel-highlight {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .purchase-plan-summary {
    justify-content: flex-start;
  }

  .purchase-plan-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .purchase-plan-button-row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .purchase-plan-inline-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .purchase-plan-filters {
    grid-template-columns: 1fr;
  }

  .clearance-inline-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .clearance-filters-bar {
    grid-template-columns: 1fr;
  }

  .profit-filters {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .batch-actions {
    gap: 6px;
  }

}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  .stats-grid,
  .analysis-grid,
  .filters,
  .filters-wide,
  .filters-new-listing,
  .profit-search-bar,
  .po-unified-search,
  .integration-form,
  .new-listing-form-grid,
  .new-listing-channel-form,
  .user-switcher {
    grid-template-columns: 1fr;
  }

  .integration-inline-actions {
    flex-direction: column;
  }

  .new-listing-remark-field {
    grid-column: span 1;
  }

  .topbar,
  .panel-highlight,
  .section-head,
  .advanced-search-head {
    flex-direction: column;
    align-items: stretch;
  }

  .purchase-plan-button-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .purchase-plan-inline-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .purchase-plan-inline-actions button {
    min-width: 0;
  }

  .clearance-inline-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .clearance-inline-actions button {
    min-width: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stale-flow-grid,
  .stale-summary-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 0;
    padding: 16px 16px 14px;
  }

  .topbar {
    padding: 18px;
  }

  .topbar-actions {
    width: 100%;
  }

  .language-switch,
  .chip {
    width: 100%;
    justify-content: space-between;
  }

  .panel-highlight {
    min-height: unset;
  }

  .panel-highlight-orbit {
    position: relative;
    left: auto;
    top: auto;
    width: 120px;
    height: 120px;
    transform: none;
    align-self: flex-end;
  }

  .advanced-search-grid {
    grid-template-columns: 1fr;
  }

  .profit-filters,
  .profit-filter-range {
    grid-template-columns: 1fr;
  }

  .topbar h1,
  .panel h2,
  .panel-highlight h2 {
    font-size: 1.45rem;
  }
}

@media (max-width: 1500px) {
  .integration-layout {
    grid-template-columns: minmax(240px, 0.78fr) minmax(360px, 1.22fr);
    gap: 16px;
  }

  #integration-output {
    min-height: 420px;
  }
}

@media (max-width: 1200px) {
  .stale-flow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .integration-layout {
    grid-template-columns: 1fr;
  }

  #integration-output {
    max-height: none;
    min-height: 320px;
  }
}
