/* 方向契约：专业桌面运营控制台。深色稳定导航、冷灰画布、白色证据面；品牌蓝只用于操作和选中，状态色只表达业务状态。优先可读、对齐、即时反馈与可追溯，不做装饰性卡片、移动端导航或花哨动效。 */

/* ---------- 01. Foundations ---------- */
:root {
  color-scheme: light;
  --canvas: #f3f6fa;
  --surface: #ffffff;
  --surface-subtle: #f7f9fc;
  --surface-selected: #edf5ff;
  --surface-disabled: #eef2f7;
  --text: #10213a;
  --text-secondary: #52627a;
  --text-tertiary: #66758b;
  --border: #dbe4ef;
  --border-strong: #b9c7d9;
  --primary: #1769e0;
  --primary-hover: #0f58c5;
  --primary-active: #0b489f;
  --primary-soft: #eaf3ff;
  --success: #14805e;
  --success-soft: #e8f6f0;
  --warning: #b86600;
  --warning-soft: #fff3df;
  --danger: #c83b45;
  --danger-soft: #fff0f1;
  --info: #2161a8;
  --info-soft: #edf5ff;
  --sidebar: #0f1f33;
  --sidebar-hover: #182c46;
  --sidebar-active: #1d4f91;
  --sidebar-text: #e8eef7;
  --sidebar-muted: #9eacc0;
  --focus-ring: rgba(23, 105, 224, 0.26);
  --overlay: rgba(15, 29, 48, 0.5);
  --shadow-overlay: 0 14px 42px rgba(15, 29, 48, 0.2);
  --shadow-surface: 0 1px 2px rgba(15, 31, 51, 0.04), 0 8px 24px rgba(15, 31, 51, 0.035);
  --shadow-raised: 0 8px 28px rgba(15, 31, 51, 0.1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --control-sm: 32px;
  --control-md: 36px;
  --control-lg: 40px;
  --sidebar-width: 224px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 72px;
  --content-max: 1480px;
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Compatibility aliases for current inline styles. */
  --bg: var(--canvas);
  --panel: var(--surface);
  --ink: var(--text);
  --muted: var(--text-secondary);
  --line: var(--border);
  --green: var(--success);
  --orange: var(--warning);
  --red: var(--danger);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 1180px;
  min-height: 100%;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 1180px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 14px/1.55 var(--font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-sans);
}

button,
input,
select,
textarea {
  font-size: 14px;
}

button,
select,
input[type="checkbox"],
input[type="radio"],
summary,
a[href] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
figure {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.28;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

p {
  color: var(--text-secondary);
  text-wrap: pretty;
}

strong,
b {
  font-weight: 700;
}

small,
.muted,
.cell-sub,
.toolbar-note,
.panel-footnote,
.heading-note,
.readonly-note {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.num,
[data-number],
.metric b,
.metric-card strong,
.product-kpi b,
.risk-card strong,
.replenishment-summary strong,
td,
time {
  font-variant-numeric: tabular-nums lining-nums;
}

::selection {
  background: #cfe3ff;
  color: var(--text);
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

input::placeholder,
textarea::placeholder {
  color: #617087;
  opacity: 1;
}

[hidden],
.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 02. Desktop application shell ---------- */
.page-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--motion-slow) var(--ease-out);
}

.page-shell > main {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #0d1d31 0%, var(--sidebar) 58%, #11253d 100%);
  color: var(--sidebar-text);
}

.brand {
  display: flex;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 14px 0 18px;
  border-bottom: 1px solid rgba(232, 238, 247, 0.14);
}

.brand-link {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: var(--sidebar-text);
}

.brand-link:hover {
  color: #ffffff;
}

.brand-mark {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-content: center;
  gap: 5px;
  border-radius: var(--radius-md);
  background: var(--primary);
}

.brand-mark span {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: #ffffff;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.brand-copy strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--sidebar-muted);
}

.sidebar-collapse {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(232, 238, 247, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-base) var(--ease-out);
}

.sidebar-collapse:hover {
  border-color: rgba(232, 238, 247, 0.38);
  background: rgba(255, 255, 255, 0.14);
}

.primary-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.nav-group + .nav-group {
  margin-top: 14px;
}

.nav-group-label {
  display: block;
  padding: 0 10px 6px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 600;
}

.primary-nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 2px 0;
  padding: 0 10px;
  gap: 10px;
  border-radius: var(--radius-md);
  color: #cbd6e5;
  border: 1px solid transparent;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}

.primary-nav a:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.primary-nav a.active,
.primary-nav a[aria-current="page"] {
  border-color: rgba(111, 171, 255, 0.2);
  background: linear-gradient(90deg, rgba(40, 111, 205, 0.92), rgba(30, 82, 148, 0.9));
  color: #ffffff;
  box-shadow: inset 3px 0 #79b3ff;
}

.primary-nav a b {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav-icon {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  color: currentColor;
  font-size: 16px;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-foot {
  display: flex;
  align-items: flex-start;
  margin: 0 14px;
  padding: 14px 4px;
  gap: 10px;
  border-top: 1px solid rgba(232, 238, 247, 0.14);
}

.sidebar-foot > span:last-child {
  display: grid;
  min-width: 0;
}

.sidebar-foot strong {
  color: var(--sidebar-text);
  font-size: 12px;
}

.sidebar-foot small {
  color: var(--sidebar-muted);
}

.sidebar-status-dot,
.status-indicator,
.data-freshness i,
.live i {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--success);
}

.sidebar-account-menu {
  position: relative;
  margin: 0 12px 12px;
  border-top: 1px solid rgba(232, 238, 247, 0.14);
  color: var(--sidebar-text);
}

.user-card {
  display: flex;
  align-items: center;
  min-height: 62px;
  padding: 10px 4px;
  gap: 10px;
  list-style: none;
}

.user-card::-webkit-details-marker,
.top-action-menu summary::-webkit-details-marker,
details > summary::-webkit-details-marker {
  display: none;
}

.avatar {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.user-card-copy {
  display: grid;
  flex: 1;
  min-width: 0;
}

.user-card-copy strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-card-copy small {
  color: var(--sidebar-muted);
}

.user-card-chevron {
  color: var(--sidebar-muted);
  transition: transform var(--motion-base) var(--ease-out);
}

.account-menu[open] .user-card-chevron {
  transform: rotate(180deg);
}

.account-menu-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 70;
  padding: 10px;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-overlay);
  color: var(--text);
}

.account-menu-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  gap: 12px;
  font-size: 12px;
}

.account-menu-row span {
  color: var(--text-secondary);
}

.account-menu-action {
  width: 100%;
  min-height: 34px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text);
  text-align: left;
}

.account-menu-action:hover {
  background: var(--primary-soft);
}

.account-menu-action.danger {
  color: var(--danger);
}

.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar-collapsed .brand {
  padding-inline: 12px;
  justify-content: center;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-group-label,
.sidebar-collapsed .primary-nav a b,
.sidebar-collapsed .sidebar-foot > span:last-child,
.sidebar-collapsed .user-card-copy,
.sidebar-collapsed .user-card-chevron {
  display: none;
}

.sidebar-collapsed .brand-link {
  flex: 0 0 auto;
}

.sidebar-collapsed .sidebar-collapse {
  position: absolute;
  right: -12px;
  transform: rotate(180deg);
  background: var(--sidebar);
}

.sidebar-collapsed .primary-nav a {
  justify-content: center;
  padding-inline: 0;
}

.sidebar-collapsed .sidebar-foot,
.sidebar-collapsed .user-card {
  justify-content: center;
}

.topbar,
.page-header {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 10px 24px;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 10px rgba(15, 31, 51, 0.035);
  backdrop-filter: blur(12px);
}

.topbar-leading,
.page-heading {
  min-width: 0;
}

.page-heading {
  display: grid;
  gap: 2px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 760;
}

.page-subtitle {
  max-width: 72ch;
  margin: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-actions,
.page-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.data-freshness,
.owner-switch,
.live {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-md);
  padding: 0 10px;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 12px;
}

.data-freshness i,
.live i {
  margin-top: 0;
}

.owner-switch select {
  min-width: 104px;
  height: 30px;
  padding-right: 24px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.global-sync-button {
  min-height: var(--control-md);
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast);
}

.global-sync-button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.global-sync-button:active,
.is-pressed {
  transform: translateY(1px);
}

.sync-button-icon {
  display: inline-block;
  margin-right: 6px;
}

.is-loading .sync-button-icon,
.global-sync-button.is-loading .sync-button-icon {
  animation: ds-spin 800ms linear infinite;
}

.top-action-menu {
  position: relative;
}

.top-action-menu > summary {
  display: grid;
  width: var(--control-md);
  height: var(--control-md);
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-secondary);
  list-style: none;
}

.top-action-menu > summary:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.top-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  display: grid;
  width: 288px;
  padding: 10px;
  gap: 4px;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-overlay);
}

.top-menu-popover a,
.top-menu-popover button,
.top-menu-note {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.top-menu-popover a:hover,
.top-menu-popover button:hover {
  background: var(--primary-soft);
}

.top-menu-note {
  color: var(--text-secondary);
  font-size: 12px;
}

.content {
  display: grid;
  width: min(calc(100% - 48px), var(--content-max));
  margin: 0 auto;
  padding: 24px 0 40px;
  gap: 16px;
}

.canonical-page,
.dashboard-page,
.analysis-page,
.family-detail-page,
.detail-workspace,
.inventory-page {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.mobile-bottom-nav,
.mobile-menu-toggle,
.mobile-nav-scrim {
  display: none;
}

/* ---------- 03. Controls ---------- */
.btn,
button.btn,
a.btn,
.text-btn,
.link-btn,
.row-action,
.quiet-link,
.panel-action-link,
.iw-primary-button,
.iw-secondary-button,
.iw-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-md);
  padding: 0 12px;
  gap: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast), transform var(--motion-fast);
}

.btn:hover,
.iw-secondary-button:hover,
.iw-upload-button:hover {
  border-color: #91a6c2;
  background: var(--surface-subtle);
  color: var(--text);
}

.btn.primary,
.iw-primary-button,
button.primary,
.primary.btn {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.btn.primary:hover,
.iw-primary-button:hover,
button.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: #ffffff;
}

.btn.danger,
.text-btn.danger,
.danger-text,
.link-btn.danger-text {
  color: var(--danger);
}

.btn.danger {
  border-color: #e6a8ae;
  background: var(--danger-soft);
}

.btn-quiet,
.text-btn,
.link-btn,
.row-action,
.quiet-link,
.panel-action-link {
  min-height: 30px;
  padding: 0 5px;
  border-color: transparent;
  background: transparent;
  color: var(--primary);
}

.text-btn:hover,
.link-btn:hover,
.row-action:hover,
.quiet-link:hover,
.panel-action-link:hover {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

button.is-loading,
.btn.is-loading,
[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.72;
}

button.is-loading::before,
.btn.is-loading::before {
  width: 14px;
  height: 14px;
  content: "";
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ds-spin 700ms linear infinite;
}

.btn:disabled,
button:disabled,
.special-filter:disabled {
  border-color: var(--border);
  background: var(--surface-disabled);
  color: #78879b;
  opacity: 1;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea,
.search {
  min-height: var(--control-md);
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  line-height: 1.35;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #91a6c2;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

label > input,
label > select,
label > textarea {
  margin-top: 5px;
}

.inline-form,
.inline-actions,
.mini-actions,
.actions,
.filters,
.panel-foot-actions,
.inventory-domestic-import-actions,
.inventory-flow-actions,
.inbound-shipment-actions,
.family-summary-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filters label,
.wizard-fields label,
.policy-settings-form label,
.finance-settings-form label,
.iw-settings-form label {
  display: grid;
  gap: 2px;
}

.search-field {
  display: grid;
  min-width: 240px;
  gap: 4px;
}

.search {
  min-width: 220px;
}

/* ---------- 04. Panels, headers, status and tabs ---------- */
.panel,
.dashboard-panel,
.overview-panel,
.v2-chart-panel,
.family-card,
.family-simple-card,
.inbound-shipment-card,
.setting-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-surface);
}

.panel,
.dashboard-panel,
.overview-panel,
.v2-chart-panel,
.setting-card {
  padding: 18px 20px;
}

.panel-head,
.panel-heading,
.section-heading,
.dashboard-section-heading,
.overview-panel-head,
.v2-chart-title,
.inventory-flow-heading,
.sales-family-inline-head,
.iw-tool-head,
.iw-card-top,
.iw-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  gap: 16px;
}

.panel-head h2,
.panel-heading h2,
.section-heading h2,
.dashboard-section-heading h2,
.overview-panel-head h2,
.v2-chart-title h2,
.inventory-flow-heading h2,
.iw-tool-head h2,
.iw-card-top h3,
.iw-result-head h3 {
  margin: 0 0 4px;
}

.panel-head p,
.panel-heading p,
.section-heading p,
.dashboard-section-heading p,
.overview-panel-head p,
.v2-chart-title p,
.inventory-flow-heading p,
.iw-tool-head p,
.iw-card-top p,
.iw-result-head p {
  max-width: 75ch;
  margin: 0;
  font-size: 13px;
}

.section-heading.compact,
.compact-heading {
  align-items: center;
}

.eyebrow,
.section-kicker,
.iw-kicker,
.iw-card-mark {
  display: none;
}

.page-scope-bar,
.dashboard-status-strip,
.overview-status-line,
.rule-note,
.product-data-note,
.failure-panel,
.analysis-data-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 10px 14px;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 13px;
}

.page-scope-bar > span:first-child,
.rule-note > span,
.product-data-note > span {
  min-width: 0;
}

.page-scope-bar strong,
.rule-note strong,
.product-data-note strong,
.failure-panel strong {
  color: var(--text);
}

.product-data-note.warning,
.failure-panel,
.analysis-data-state {
  border-color: #edcf9f;
  background: var(--warning-soft);
  color: #70430a;
}

.scope-status,
.status-badge,
.badge,
.tag,
.sku-state-chip,
.scope-filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
}

.scope-status.warning,
.badge.warning,
.status-warning,
.sku-state-chip.warning {
  border-color: #edcf9f;
  background: var(--warning-soft);
  color: #855006;
}

.badge.success,
.status-success,
.scope-status.success,
.sku-state-chip.success {
  border-color: #a8dcc8;
  background: var(--success-soft);
  color: #0f684c;
}

.badge.danger,
.status-danger,
.sku-state-chip.danger {
  border-color: #efb5ba;
  background: var(--danger-soft);
  color: #a72d37;
}

.badge.info,
.status-info,
.scope-status.info {
  border-color: #b8d2f2;
  background: var(--info-soft);
  color: #174f8d;
}

.subnav,
.page-tabs,
.analysis-tabs,
.period-tabs,
.product-view-switch,
.special-filter-bar,
.reference-filter-bar,
.chart-switch,
.iw-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 44px;
  padding: 6px;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.subnav a,
.page-tabs a,
.analysis-tabs a,
.period-tabs a,
.product-view-switch button,
.special-filter,
.reference-filter-bar a,
.chart-switch button,
.iw-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-sm);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 650;
}

.subnav a:hover,
.page-tabs a:hover,
.analysis-tabs a:hover,
.period-tabs a:hover,
.product-view-switch button:hover,
.special-filter:hover,
.reference-filter-bar a:hover,
.chart-switch button:hover,
.iw-tabs a:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.subnav .active,
.page-tabs .active,
.analysis-tabs .active,
.period-tabs .active,
.product-view-switch .active,
.special-filter.active,
.reference-filter-bar .active,
.chart-switch .active,
.iw-tabs .active {
  border-color: #bed8fb;
  background: var(--primary-soft);
  color: var(--primary);
}

.reference-filter-bar,
.ledger-toolbar,
.family-toolbar,
.toolbar-panel,
.canonical-filter,
.table-action-bar,
.detail-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.reference-filter-bar {
  padding: 10px 12px;
}

.product-filter-group,
.product-filter-actions,
.ledger-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-page-toolbar {
  min-height: 42px;
  padding: 6px 0;
  color: var(--text-secondary);
}

/* ---------- 05. MetricStrip and current metrics ---------- */
.MetricStrip,
.ds-metric-strip,
.metric-grid,
.product-kpi-grid,
.family-detail-kpis,
.family-config-kpis,
.dashboard-kpis,
.inventory-replenishment-strip,
.domestic-summary-grid,
.inbound-metrics,
.mini-metrics,
.yesterday-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.metric-grid > *,
.product-kpi-grid > *,
.family-detail-kpis > *,
.family-config-kpis > *,
.dashboard-kpis .metric-card,
.inventory-replenishment-strip > *,
.domestic-summary-grid > *,
.inbound-metrics > *,
.mini-metrics > *,
.yesterday-metrics > *,
.MetricStrip > *,
.ds-metric-strip > * {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 92px;
  padding: 14px 16px;
  gap: 3px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.metric-grid > *:last-child,
.product-kpi-grid > *:last-child,
.family-detail-kpis > *:last-child,
.family-config-kpis > *:last-child,
.dashboard-kpis .metric-card:last-child,
.inventory-replenishment-strip > *:last-child,
.MetricStrip > *:last-child,
.ds-metric-strip > *:last-child {
  border-right: 0;
}

.metric-grid > button:hover,
.metric-grid > a:hover,
.metric-card[href]:hover,
.risk-card[href]:hover,
.replenishment-summary[href]:hover {
  background: var(--surface-subtle);
}

.metric-grid > .active,
.metric-card.metric-primary,
.product-kpi.primary,
.replenishment-summary.primary {
  background: var(--surface-selected);
}

.metric span,
.metric-card > span,
.metric-label,
.product-kpi > span,
.risk-card > span,
.replenishment-summary > span,
.domestic-summary-grid span,
.mini-metrics span,
.yesterday-metrics small {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.metric b,
.metric-card strong,
.product-kpi b,
.risk-card strong,
.replenishment-summary strong,
.domestic-summary-grid strong,
.mini-metrics b,
.yesterday-metrics strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
}

.metric small,
.metric-card small,
.product-kpi small,
.risk-card small,
.replenishment-summary small {
  color: var(--text-secondary);
  font-size: 12px;
}

.metric.danger b,
.product-kpi.danger b,
.risk-card.danger strong,
.metric-warning,
.danger-soft b {
  color: var(--danger);
}

.metric.warning b,
.product-kpi.warning b,
.risk-card.warning strong,
.replenishment-summary.warning strong {
  color: var(--warning);
}

.metric.success b,
.product-kpi.success b,
.risk-card.success strong {
  color: var(--success);
}

/* ---------- 06. DataTable ---------- */
.DataTable,
.ds-data-table,
.canonical-table,
.overview-table,
.dashboard-table,
.order-table,
.inbound-sku-table,
.family-detail-table,
.family-member-table table,
.iw-table-wrap table,
.table-panel table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.table-scroll,
.table-wrap,
.overview-table-wrap,
.ds-data-table-scroll,
.iw-table-wrap {
  position: relative;
  max-height: min(68vh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: #b8c6d9 transparent;
}

.panel > .table-scroll,
.panel > .table-wrap,
.overview-panel > .overview-table-wrap,
.table-panel > .table-wrap {
  margin-top: 14px;
}

.DataTable th,
.DataTable td,
.ds-data-table th,
.ds-data-table td,
.canonical-table th,
.canonical-table td,
.overview-table th,
.overview-table td,
.dashboard-table th,
.dashboard-table td,
.order-table th,
.order-table td,
.inbound-sku-table th,
.inbound-sku-table td,
.table-panel table th,
.table-panel table td,
.iw-table-wrap th,
.iw-table-wrap td {
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
}

table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 40px;
  background: #f1f5fa;
  color: #3f526c;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

table thead tr:nth-child(2) th {
  top: 40px;
  z-index: 4;
}

table tbody tr:last-child > td {
  border-bottom: 0;
}

table tbody tr:not(.order-detail):not(.sales-family-detail-row):hover > td {
  background: #f8fbff;
}

table td > strong,
table td > b {
  display: inline-block;
  color: var(--text);
}

table td > small,
.order-identity small,
.product-cell small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
}

th.num,
td.num {
  text-align: right;
}

.compact-table th,
.compact-table td {
  padding-block: 9px;
}

.empty,
.empty-state,
.StatePanel,
.ds-state-panel {
  color: var(--text-secondary);
  text-align: center;
}

.empty-state,
.StatePanel,
.ds-state-panel {
  display: grid;
  min-height: 120px;
  padding: 24px;
  place-content: center;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.empty-state strong,
.StatePanel strong,
.ds-state-panel strong {
  color: var(--text);
  font-size: 15px;
}

.ds-state-panel[data-ds-state="error"],
.StatePanel.error,
[data-state="error"] {
  border-color: #efb5ba;
  background: var(--danger-soft);
  color: #8f2a33;
}

.ds-state-panel[data-ds-state="loading"],
.StatePanel.loading,
[data-state="loading"] {
  border-style: solid;
  background: var(--surface-subtle);
}

.skeleton {
  width: 100%;
  min-height: 120px;
  border-radius: var(--radius-md);
  background: #e9eef5;
  animation: ds-pulse 1.4s ease-in-out infinite;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-right-color: var(--primary);
  border-radius: 50%;
  animation: ds-spin 700ms linear infinite;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-top: 12px;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.pagination-bar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-table-floating-head {
  display: none;
}

/* ---------- 07. DisclosureRow ---------- */
.DisclosureRow,
.ds-disclosure-row,
.inventory-product-row {
  transition: background var(--motion-fast);
}

.DisclosureRow[aria-expanded="true"],
.ds-disclosure-row.is-expanded,
.ds-disclosure-row:has(.ds-disclosure-trigger[aria-expanded="true"]),
.inventory-product-row:has(.inventory-toggle[aria-expanded="true"]) {
  background: var(--surface-selected);
}

.ds-disclosure-trigger,
.inventory-toggle,
.expand-order {
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}

.inventory-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 4px 2px;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.inventory-toggle .chevron,
.expand-order svg,
.ds-disclosure-trigger .chevron {
  transition: transform var(--motion-base) var(--ease-out);
}

.inventory-toggle[aria-expanded="true"] .chevron,
.expand-order[aria-expanded="true"] svg,
.ds-disclosure-trigger[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.ds-disclosure-panel > td,
.inventory-detail-row > td,
.sales-family-detail-row > td,
.order-detail > td {
  padding: 0;
  background: var(--surface-subtle);
}

.DisclosureRow__content,
.ds-disclosure-content,
[data-ds-bounded-content],
.inventory-inline-skus,
.sales-family-inline-detail,
.order-products,
.family-detail,
.inbound-detail {
  max-height: 360px;
  padding: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface-subtle);
}

.ds-disclosure-content .table-scroll,
.inventory-inline-skus .table-scroll,
.sales-family-inline-detail .overview-table-wrap {
  max-height: 300px;
  margin-top: 10px;
}

.expand-order {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 7px;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--primary);
  font-size: 12px;
}

.expand-order svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.order-group:has(.order-select:checked) .order-main td {
  background: var(--surface-selected);
}

/* ---------- 08. SideDrawer and dialogs ---------- */
.SideDrawer,
.side-drawer,
.ds-side-drawer,
[data-ds-drawer] {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 90;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(560px, 44vw);
  height: 100vh;
  background: var(--surface);
  box-shadow: -14px 0 42px rgba(15, 29, 48, 0.18);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform var(--motion-slow) var(--ease-out), visibility 0s linear var(--motion-slow);
}

.SideDrawer.is-open,
.side-drawer.is-open,
.ds-side-drawer.is-open,
[data-ds-drawer][data-state="open"],
[data-ds-drawer][open] {
  transform: translateX(0);
  visibility: visible;
  transition-delay: 0s;
}

.SideDrawer__header,
.SideDrawer__footer,
.ds-drawer-header,
.ds-drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.SideDrawer__footer,
.ds-drawer-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.SideDrawer__body,
.ds-drawer-body {
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
}

.SideDrawerBackdrop,
.side-drawer-backdrop,
.ds-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--motion-base), visibility 0s linear var(--motion-base);
}

.SideDrawerBackdrop.is-open,
.side-drawer-backdrop.is-open,
.ds-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

dialog {
  max-width: min(680px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  color: var(--text);
}

dialog::backdrop {
  background: var(--overlay);
}

.page-help-dialog,
.tc-query-dialog {
  width: min(640px, calc(100vw - 64px));
  padding: 0;
}

.page-help-dialog .panel-head,
.tc-query-dialog .panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.page-help-body,
.tc-query-body {
  max-height: 60vh;
  padding: 20px;
  overflow: auto;
}

.page-help-body li + li {
  margin-top: 8px;
}

/* ---------- 09. Toast and immediate feedback ---------- */
.toast-region {
  position: fixed;
  top: 88px;
  right: 24px;
  z-index: 110;
  display: grid;
  width: min(380px, calc(100vw - 48px));
  gap: 8px;
  pointer-events: none;
}

.toast,
.toast-region > * {
  display: flex;
  align-items: flex-start;
  min-height: 46px;
  padding: 12px 14px;
  gap: 10px;
  border-radius: var(--radius-md);
  background: #17283f;
  box-shadow: 0 8px 24px rgba(15, 29, 48, 0.18);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
}

.toast-region > .toast {
  animation: ds-toast-in var(--motion-base) var(--ease-out) both;
}

.toast-region > .toast.is-leaving,
.toast-region > .toast[data-state="leaving"] {
  animation: ds-toast-out var(--motion-fast) ease-in both;
}

body > .toast {
  position: fixed;
  top: 88px;
  right: 24px;
  z-index: 110;
  max-width: 380px;
  opacity: 0;
  transform: translateY(-8px);
  visibility: hidden;
  transition: opacity var(--motion-base), transform var(--motion-base) var(--ease-out), visibility 0s linear var(--motion-base);
}

body > .toast.show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition-delay: 0s;
}

.toast.success,
.toast.toast-success,
.toast-region > .success,
.toast-region > .toast-success,
[data-toast-type="success"] {
  background: #0f684c;
}

.toast.warning,
.toast.toast-warning,
.toast-region > .warning,
.toast-region > .toast-warning,
[data-toast-type="warning"] {
  background: #80500d;
}

.toast.danger,
.toast.toast-danger,
.toast-region > .danger,
.toast-region > .toast-danger,
[data-toast-type="danger"],
[data-toast-type="error"] {
  background: #922b34;
}

.toast-close,
[data-toast-close] {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin: -3px -5px -3px auto;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #ffffff;
  font-size: 17px;
  line-height: 1;
  opacity: 0.76;
  transition: background var(--motion-fast), opacity var(--motion-fast);
}

.toast-close:hover,
[data-toast-close]:hover {
  background: rgba(255, 255, 255, 0.14);
  opacity: 1;
}

.toast-close:focus-visible,
[data-toast-close]:focus-visible {
  outline-color: rgba(255, 255, 255, 0.75);
}

/* ---------- 10. Dashboard ---------- */
.dashboard-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 4px;
  gap: 24px;
}

.dashboard-intro h2 {
  margin: 0 0 5px;
  font-size: 24px;
}

.dashboard-intro p {
  max-width: 68ch;
  margin: 0;
}

.intro-date {
  display: grid;
  justify-items: end;
  color: var(--text-secondary);
  font-size: 12px;
}

.intro-date strong {
  color: var(--text);
  font-size: 14px;
}

.dashboard-priority,
.dashboard-kpis {
  display: grid;
  gap: 10px;
}

.priority-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.priority-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
  min-height: 94px;
  padding: 16px;
  align-items: center;
  gap: 12px;
  border-right: 1px solid var(--border);
  color: var(--text);
  transition: background var(--motion-fast);
}

.priority-card:last-child {
  border-right: 0;
}

.priority-card:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.priority-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 700;
}

.priority-danger .priority-icon { background: var(--danger-soft); color: var(--danger); }
.priority-warning .priority-icon { background: var(--warning-soft); color: var(--warning); }
.priority-neutral .priority-icon { background: var(--primary-soft); color: var(--primary); }

.priority-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.priority-copy > strong {
  font-size: 14px;
}

.priority-copy > b {
  font-size: 22px;
  line-height: 1.15;
}

.priority-copy > b small,
.priority-copy > small {
  color: var(--text-secondary);
  font-size: 12px;
}

.priority-arrow {
  color: var(--text-tertiary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.dashboard-evidence-grid,
.dashboard-detail-grid,
.analysis-main-grid,
.analysis-secondary-grid,
.analysis-signal-grid,
.product-visual-grid,
.v2-split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.85fr);
  gap: 16px;
}

.analysis-main-grid {
  grid-template-columns: minmax(0, 1.72fr) minmax(340px, 0.78fr);
}

.analysis-secondary-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
}

.dashboard-detail-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.yesterday-panel {
  grid-column: 1 / -1;
}

.dashboard-chart,
.overview-chart,
.echart-box {
  min-height: 280px;
}

.dashboard-panel .table-scroll {
  max-height: 360px;
}

.panel-heading + .order-overview,
.panel-heading + .store-rank-list,
.panel-heading + .table-scroll,
.overview-panel-head + .product-share-board,
.overview-panel-head + .overview-chart {
  margin-top: 14px;
}

.order-overview,
.structure-visual {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  min-height: 210px;
  gap: 18px;
}

.order-total,
.structure-ring,
.product-share-ring {
  display: grid;
  width: 124px;
  height: 124px;
  place-content: center;
  border: 10px solid #dceaff;
  border-top-color: var(--primary);
  border-radius: 50%;
  text-align: center;
}

.order-total strong,
.structure-ring strong,
.product-share-ring b {
  color: var(--text);
  font-size: 27px;
}

.order-total span,
.structure-ring small,
.product-share-ring span {
  color: var(--text-secondary);
  font-size: 12px;
}

.order-state-list,
.structure-visual ul {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-state-list > div,
.structure-visual li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 38px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.state-dot,
.dot,
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--info);
}

.state-dot.warning,
.dot.orange { background: var(--warning); }
.state-dot.success,
.dot.green { background: var(--success); }
.state-dot.danger { background: var(--danger); }
.dot.blue { background: var(--primary); }
.dot.purple { background: #7655c5; }

.panel-action-link {
  margin-top: 8px;
}

.store-rank-list,
.rank-list,
.action-list,
.signal-list,
.product-share-list {
  display: grid;
}

.store-rank-list a,
.rank-list a,
.action-row,
.signal-row,
.product-share-list a {
  display: grid;
  align-items: center;
  min-height: 48px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.store-rank-list a {
  grid-template-columns: 28px minmax(0, 1fr) auto;
}

.store-rank-number,
.rank-badge,
.rank-number {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
}

.store-rank-copy {
  display: grid;
  gap: 6px;
}

.store-rank-copy i,
.share-meter {
  position: relative;
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #e8eef5;
}

.store-rank-copy i em,
.share-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.share-meter {
  display: flex;
  align-items: center;
  min-width: 120px;
  overflow: visible;
}

.share-meter span {
  position: absolute;
  left: calc(100% + 8px);
  color: var(--text-secondary);
  font-size: 12px;
}

.dashboard-source-note,
.dashboard-status-strip,
.dashboard-source-note {
  margin: 0;
  font-size: 12px;
}

/* ---------- 11. Analysis and sales ---------- */
.analysis-toolbar {
  padding: 6px;
}

.analysis-hero,
.family-detail-hero,
.domestic-detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 116px;
  padding: 20px 22px;
  gap: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(112deg, #ffffff 0%, #f7fbff 68%, #edf5ff 100%);
  box-shadow: var(--shadow-surface);
}

.analysis-decision-strip {
  position: relative;
  overflow: hidden;
  border-color: #cbdcf2;
}

.analysis-decision-strip::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  content: "";
  background: var(--primary);
}

.analysis-decision-copy {
  min-width: 0;
}

.decision-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
}

.analysis-decision-copy h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.analysis-hero h2,
.family-detail-hero h2,
.domestic-detail-hero h2 {
  margin: 0 0 5px;
}

.analysis-hero p,
.family-detail-hero p,
.domestic-detail-hero p {
  max-width: 72ch;
  margin: 0;
}

.analysis-hero-meta,
.family-main-sku {
  display: grid;
  flex: 0 0 230px;
  padding-left: 20px;
  gap: 2px;
  border-left: 1px solid var(--border);
}

.analysis-hero-meta span,
.family-main-sku span {
  color: var(--text-secondary);
  font-size: 12px;
}

.analysis-hero-meta strong,
.family-main-sku strong {
  font-size: 17px;
}

.trend-chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 250px;
  padding: 28px 12px 8px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 49px, #edf1f6 50px);
}

.trend-column {
  display: grid;
  flex: 1;
  min-width: 28px;
  height: 210px;
  grid-template-rows: 22px minmax(0, 1fr) 20px;
  justify-items: center;
  align-items: end;
}

.trend-column i {
  width: min(28px, 70%);
  height: var(--bar-height, 4%);
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #2f7dea 0%, var(--primary) 100%);
  box-shadow: 0 6px 14px rgba(23, 105, 224, 0.14);
  transform-origin: bottom;
  animation: ds-chart-grow 520ms var(--ease-out) both;
  animation-delay: calc(var(--bar-index, 0) * 45ms);
  transition: filter var(--motion-fast), transform var(--motion-fast);
}

.trend-column:hover i {
  filter: saturate(1.2) brightness(1.04);
  transform: scaleX(1.12);
}

.trend-value,
.trend-column small {
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.rank-list a {
  grid-template-columns: 28px minmax(0, 1fr) auto;
  padding-block: 8px;
}

.rank-list a:hover,
.signal-row:hover,
.action-row:hover {
  background: var(--surface-subtle);
}

.rank-share {
  display: block;
  height: 4px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 2px;
  background: #e7edf5;
}

.rank-share > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fbdf8, var(--primary));
  animation: ds-share-grow 520ms var(--ease-out) both;
}

.rank-list a > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.rank-list a > div,
.signal-row > div,
.action-row > div {
  display: grid;
  min-width: 0;
}

.rank-list small,
.signal-row small,
.action-row small {
  color: var(--text-secondary);
  font-size: 12px;
}

.action-row {
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  min-height: 62px;
  padding: 9px 8px;
  border-left: 3px solid transparent;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}

.action-row.tone-warning { border-left-color: var(--warning); }
.action-row.tone-danger { border-left-color: var(--danger); }
.action-row.tone-success { border-left-color: var(--success); }
.action-row.tone-warning .status-dot { background: var(--warning); }
.action-row.tone-danger .status-dot { background: var(--danger); }
.action-row.tone-success .status-dot { background: var(--success); }

.action-row em {
  color: var(--primary);
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
  white-space: nowrap;
}

.analysis-action-queue .action-list {
  margin-top: 12px;
}

.structure-ledger {
  display: grid;
  margin: 14px 0 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.structure-ledger > div {
  display: grid;
  min-height: 84px;
  padding: 14px 16px;
  align-content: center;
  gap: 3px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.structure-ledger dt {
  color: var(--text-secondary);
  font-size: 12px;
}

.structure-ledger dd {
  margin: 0;
  color: var(--text);
  font-size: 25px;
  font-weight: 760;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.structure-ledger dd small {
  margin-left: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.success-state {
  border-color: #b8decf;
  background: var(--success-soft);
  color: #155f49;
}

.signal-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.7fr) auto;
  padding-block: 8px;
}

.signal-row > span {
  display: grid;
}

.signal-row em {
  color: var(--primary);
  font-style: normal;
  font-size: 12px;
}

.zero-sales-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.zero-sales-family-grid,
.zero-sales-diagnosis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.zero-sales-family-grid > a,
.zero-sales-diagnosis-grid > article {
  display: grid;
  min-height: 76px;
  padding: 14px;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}

@keyframes ds-chart-grow {
  from { transform: scaleY(0.04); opacity: 0.35; }
  to { transform: scaleY(1); opacity: 1; }
}

@keyframes ds-share-grow {
  from { transform: scaleX(0); transform-origin: left; }
  to { transform: scaleX(1); transform-origin: left; }
}

.zero-sales-family-list {
  display: grid;
  gap: 10px;
}

.zero-sales-family-card {
  overflow: hidden;
}

.zero-sales-family-card > summary,
.family-simple-card > summary,
.inbound-family-card > summary,
.inbound-shipment-card > summary,
.simple-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 12px 16px;
  gap: 16px;
  list-style: none;
}

.zero-sales-family-card[open] > summary,
.family-simple-card[open] > summary,
.inbound-family-card[open] > summary,
.inbound-shipment-card[open] > summary,
.simple-section[open] > summary {
  background: var(--surface-selected);
}

.zero-sales-family-card > .table-scroll {
  max-height: 360px;
  margin: 0 16px 16px;
}

.product-share-board {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  min-height: 250px;
  gap: 24px;
}

.product-share-list a {
  grid-template-columns: 10px minmax(0, 1fr) auto;
  min-height: 40px;
}

.product-share-list i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.product-data-note {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.trend-up {
  color: var(--success);
  font-weight: 700;
}

.trend-down,
.risk-number,
.text-danger {
  color: var(--danger);
  font-weight: 700;
}

.family-detail-note {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---------- 12. Inventory ---------- */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.risk-card {
  display: grid;
  min-height: 92px;
  padding: 14px;
  gap: 3px;
  border-right: 1px solid var(--border);
  color: var(--text);
}

.risk-card:last-child {
  border-right: 0;
}

.inventory-filter-panel,
.inventory-domestic-import,
.inventory-flow-panel,
.inventory-table-panel {
  padding: 16px 18px;
}

.inventory-domestic-import {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.inventory-domestic-import-copy {
  min-width: 0;
}

.inventory-flow-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.inventory-flow-grid article {
  display: grid;
  min-height: 84px;
  padding: 13px 14px;
  gap: 2px;
  border-right: 1px solid var(--border);
}

.inventory-flow-grid article:last-child {
  border-right: 0;
}

.inventory-flow-grid span,
.inventory-flow-grid small {
  color: var(--text-secondary);
  font-size: 12px;
}

.inventory-flow-grid strong {
  font-size: 21px;
}

.inventory-flow-grid .all-stock {
  background: var(--surface-selected);
}

.inventory-product-table {
  min-width: 1240px;
}

.inventory-product-table th:first-child,
.inventory-product-table td:first-child {
  min-width: 220px;
}

.inventory-product-table th:not(:first-child),
.inventory-product-table td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.inventory-detail-table {
  min-width: 1120px;
}

.replenishment-qty {
  display: grid;
  justify-items: end;
}

.replenishment-label {
  color: var(--warning);
  font-size: 12px;
}

/* ---------- 13. Orders ---------- */
#orderCards {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

#orderCards .metric {
  min-height: 84px;
}

.special-filter-bar {
  justify-content: flex-start;
}

.special-filter-bar > span:last-child {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 12px;
}

.v2-split-grid.order-reference-split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.v2-bars {
  display: grid;
  margin-top: 14px;
  gap: 10px;
}

.v2-bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.v2-bar-label,
.v2-bar-value {
  font-size: 12px;
}

.v2-bar-value {
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
}

.v2-bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e8eef5;
}

.v2-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.advisor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.advisor-grid article {
  min-height: 92px;
  padding: 14px;
  border-right: 1px solid var(--border);
}

.advisor-grid article:last-child {
  border-right: 0;
}

.advisor-grid p {
  margin: 5px 0 0;
  font-size: 12px;
}

.toolbar-panel {
  padding: 14px 16px;
}

.toolbar-panel .actions {
  margin-left: auto;
}

.toolbar-note {
  flex-basis: 100%;
}

.order-results-panel {
  padding: 0;
  overflow: hidden;
}

.order-results-panel > .panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.order-results-panel > .table-wrap {
  max-height: calc(100vh - 260px);
  margin: 0;
  border: 0;
  border-radius: 0;
}

.order-table {
  min-width: 1420px;
}

.order-select-col,
.order-select-cell {
  width: 42px;
  text-align: center;
}

.order-disclosure-col,
.order-disclosure-cell {
  width: 68px;
}

.order-identity {
  display: grid;
  min-width: 210px;
  gap: 2px;
}

.order-products {
  min-height: 84px;
}

.order-products > p {
  margin: 0;
}

.order-detail-loading,
.order-detail-error {
  display: grid;
  min-height: 92px;
  place-content: center;
  color: var(--text-secondary);
}

/* ---------- 14. Inbound and domestic inbound ---------- */
.inbound-family-list,
.family-list,
.family-simple-list,
.inbound-shipment-list {
  display: grid;
  gap: 10px;
}

.family-card,
.family-simple-card,
.inbound-shipment-card {
  overflow: hidden;
}

.family-card > summary,
.inbound-family-card > summary {
  min-height: 68px;
}

.family-numbers {
  display: flex;
  align-items: center;
  gap: 24px;
}

.family-numbers span {
  display: grid;
  min-width: 80px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: right;
}

.family-numbers b {
  color: var(--text);
  font-size: 16px;
}

.inbound-group-actions,
.tc-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.tc-bulk-bar {
  position: sticky;
  top: calc(var(--topbar-height) + 8px);
  z-index: 20;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid #bed8fb;
  border-radius: var(--radius-md);
  background: #edf5ff;
}

.inbound-shipment-card {
  border-radius: var(--radius-md);
}

.inbound-shipment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tc-select-control {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-md);
  padding: 0 10px;
  gap: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.inbound-sku-table {
  min-width: 620px;
}

.shipment-other-items {
  margin-top: 10px;
}

.shipment-other-items > summary {
  color: var(--primary);
  font-weight: 650;
}

.domestic-detail-table {
  padding: 16px 18px;
}

.domestic-pending-table {
  min-width: 1040px;
}

/* ---------- 15. Family mapping, stores and settings ---------- */
.shared-family-grid,
.family-member-table,
.sku-pick-grid,
.store-grid,
.operator-list,
.settings-grid,
.onboarding-steps {
  display: grid;
  gap: 10px;
}

.shared-family-grid {
  grid-template-columns: 1fr;
  margin-top: 12px;
}

.shared-family-head,
.shared-family-option,
.family-table-head,
.family-member-row,
.family-member-head {
  display: grid;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.shared-family-head,
.shared-family-option {
  grid-template-columns: 72px minmax(180px, 0.8fr) minmax(260px, 1.3fr) 120px;
}

.shared-family-head,
.family-table-head,
.family-member-head {
  background: #f1f5fa;
  color: #3f526c;
  font-size: 12px;
  font-weight: 700;
}

.family-table-head {
  grid-template-columns: minmax(260px, 1fr) 110px 220px;
}

.family-simple-card > summary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 110px 220px;
}

.family-editor {
  display: grid;
  max-height: 360px;
  padding: 16px;
  gap: 14px;
  overflow: auto;
  background: var(--surface-subtle);
}

.family-member-head,
.family-member-row {
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.3fr) minmax(240px, auto);
}

.family-member-table {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.wizard-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.sku-pick-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 12px;
}

.sku-pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 10px 12px;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.sku-pick-item label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.store-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-top: 12px;
}

.store-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 132px;
  padding: 16px;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.store-card h3 {
  margin: 0 0 8px;
}

.platform {
  display: inline-flex;
  min-height: 24px;
  padding: 2px 8px;
  align-items: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.onboarding-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.onboarding-steps article {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.operator-list article {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 0.8fr) auto;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.operator-list article > div:first-child {
  display: grid;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.settings-grid .wide {
  grid-column: 1 / -1;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.policy-settings-form,
.finance-settings-form,
.iw-settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.policy-settings-form .btn,
.finance-settings-form .btn,
.iw-settings-form .iw-primary-button {
  align-self: end;
  justify-self: start;
}

/* ---------- 16. Login, password and error pages ---------- */
body:not(.page-shell):has(.login-panel),
body:not(.page-shell):has(.password-panel),
.error-page {
  display: grid;
  min-height: 100vh;
  padding: 32px;
  place-items: center;
  background: var(--canvas);
}

.login-panel,
.password-panel,
.error-card {
  width: min(440px, calc(100vw - 64px));
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.login-panel h1,
.password-panel h1,
.error-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-panel p,
.password-panel p,
.error-card p {
  margin: 0 0 20px;
}

.login-panel label,
.password-panel label {
  display: grid;
  margin-top: 14px;
  gap: 4px;
}

.login-panel input,
.password-panel input {
  width: 100%;
  min-height: var(--control-lg);
}

.login-panel > .btn,
.password-panel > .btn {
  width: 100%;
  min-height: var(--control-lg);
  margin-top: 18px;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid #efb5ba;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: #922b34;
}

.login-foot {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 12px;
}

.error-code {
  color: var(--danger);
  font: 700 13px/1.4 var(--font-mono);
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  margin-top: 20px;
  gap: 8px;
}

/* ---------- 17. Image workbench compatibility ---------- */
.iw-page {
  display: grid;
  gap: 16px;
}

.iw-intro,
.iw-tool-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.iw-intro h2,
.iw-tool-head h2 {
  margin: 0 0 6px;
}

.iw-intro p,
.iw-tool-head p {
  max-width: 72ch;
  margin: 0;
}

.iw-view,
.iw-step-card,
.iw-result,
.iw-tool-panel,
.iw-canvas-wrap,
.iw-settings-form {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.iw-view,
.iw-result,
.iw-tool-panel,
.iw-settings-form {
  padding: 20px;
}

.iw-process-form {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(260px, 0.75fr);
  gap: 16px;
}

.iw-step-card {
  padding: 18px;
}

.iw-step-no {
  display: inline-grid;
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font: 700 12px/1 var(--font-mono);
}

.iw-dropzone {
  display: grid;
  min-height: 180px;
  margin-top: 14px;
  padding: 24px;
  place-content: center;
  justify-items: center;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  text-align: center;
}

.iw-dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.iw-drop-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 22px;
}

.iw-file-summary,
.iw-form-note,
.iw-output-line,
.iw-progress-meta {
  color: var(--text-secondary);
  font-size: 12px;
}

.iw-check-list {
  display: grid;
  margin-top: 14px;
  gap: 8px;
}

.iw-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 56px;
  padding: 10px;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.iw-check span {
  display: grid;
}

.iw-check i {
  color: var(--text-tertiary);
  font: 700 11px/1 var(--font-mono);
}

.iw-select,
.iw-primary-button,
.iw-secondary-button,
.iw-frame-pick {
  width: 100%;
  margin-top: 10px;
}

.iw-progress {
  margin-top: 16px;
}

.iw-progress-meta,
.iw-output-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.iw-progress-track {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e8eef5;
}

.iw-progress-track > span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.iw-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.iw-stat-row > div {
  display: grid;
  min-height: 64px;
  padding: 10px;
  place-content: center;
  border-right: 1px solid var(--border);
  text-align: center;
}

.iw-stat-row > div:last-child {
  border-right: 0;
}

.iw-result-actions,
.iw-frame-modes {
  display: flex;
  flex-wrap: wrap;
  margin-top: 16px;
  gap: 8px;
}

.iw-frame-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
}

.iw-canvas-wrap {
  position: relative;
  display: grid;
  min-height: 560px;
  padding: 16px;
  place-items: center;
  overflow: hidden;
}

.iw-canvas-empty,
.iw-empty-state {
  display: grid;
  min-height: 220px;
  place-content: center;
  justify-items: center;
  color: var(--text-secondary);
  text-align: center;
}

.iw-history-list,
.iw-quality-result {
  display: grid;
  margin-top: 16px;
  gap: 10px;
}

.iw-log {
  max-height: 280px;
  padding: 12px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: #0f1f33;
  color: #dbe7f5;
  font: 12px/1.55 var(--font-mono);
}

/* ---------- 18. Explicit DS contracts and migrated screens ---------- */
.ds-page {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.ds-section {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.ds-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  gap: 16px;
}

.ds-work-surface {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.ds-page-intro {
  min-height: 96px;
}

.ds-page-footnote {
  color: var(--text-secondary);
  font-size: 12px;
}

.data-trust-bar,
.ds-data-trust-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 9px 12px;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 12px;
}

.ds-data-trust-items {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.ds-data-trust-items > span + span,
.data-trust-bar > span + span {
  position: relative;
}

.ds-data-trust-items > span + span::before,
.data-trust-bar > span + span::before {
  position: absolute;
  top: 50%;
  left: -8px;
  width: 1px;
  height: 14px;
  content: "";
  background: var(--border);
  transform: translateY(-50%);
}

.trust-state {
  color: var(--success);
  font-weight: 700;
}

.metric-strip,
.ds-metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.metric-strip > *,
.ds-metric-item {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 88px;
  padding: 13px 16px;
  gap: 3px;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: background var(--motion-fast), box-shadow var(--motion-fast);
}

a.ds-metric-item:hover {
  z-index: 1;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  color: var(--text);
  box-shadow: inset 0 3px var(--primary);
}

.metric-strip > *:last-child,
.ds-metric-item:last-child {
  border-right: 0;
}

.metric-strip span,
.ds-metric-item > span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.metric-strip strong,
.ds-metric-item > strong,
.ds-metric-item > b {
  color: var(--text);
  font-size: 23px;
  line-height: 1.2;
}

.metric-strip small,
.ds-metric-item > small {
  color: var(--text-secondary);
  font-size: 12px;
}

.ds-metric-item.green > strong,
.ds-metric-item.success > strong { color: var(--success); }
.ds-metric-item.orange > strong,
.ds-metric-item.warning > strong { color: var(--warning); }
.ds-metric-item.danger > strong { color: var(--danger); }
.ds-metric-item.blue > strong,
.ds-metric-item.cyan > strong { color: var(--primary); }
.ds-metric-item.purple > strong { color: #6847b8; }

.command-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 16px;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.ds-analysis-nav,
.ds-context-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ds-analysis-nav {
  border: 0;
  background: transparent;
}

.ds-analysis-nav a {
  min-height: var(--control-md);
}

.ds-context-nav {
  min-height: 42px;
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.ds-context-nav > span {
  flex: 1;
  text-align: center;
}

.ds-evidence-grid {
  min-width: 0;
}

.ds-action-list {
  min-width: 0;
}

.ds-action-item {
  min-width: 0;
}

.ds-business-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-subtle);
}

.ds-disclosure-region,
.ds-disclosure-list {
  min-width: 0;
}

.ds-drawer {
  inset: 0 0 0 auto;
  width: min(580px, 46vw);
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
}

.ds-drawer-surface {
  display: grid;
  grid-template-rows: auto minmax(0, auto) minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  background: var(--surface);
}

.ds-drawer-header {
  border-bottom: 1px solid var(--border);
}

.ds-drawer-body {
  min-height: 0;
}

.ds-drawer-section {
  min-width: 0;
  padding: 16px 20px;
  overflow: auto;
  border-top: 1px solid var(--border);
}

.ds-drawer-section h3 {
  margin: 0 0 8px;
}

.ds-drawer-evidence {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ds-drawer-evidence > * {
  display: grid;
  min-height: 58px;
  padding: 10px 12px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.ds-drawer-footer {
  justify-content: flex-end;
}

.analysis-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.analysis-metrics .ds-metric-item {
  min-height: 98px;
  padding-inline: 18px;
}

.analysis-metrics .ds-metric-item > strong {
  color: var(--text);
  font-size: 26px;
  letter-spacing: -0.025em;
}

.evidence-count {
  display: inline-flex;
  min-height: 28px;
  padding: 3px 9px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.evidence-panel,
.evidence-table-panel,
.signal-evidence-panel,
.chart-panel,
.structure-panel,
.trend-panel,
.order-panel,
.product-panel {
  min-width: 0;
}

.compact-empty,
.zero-sales-empty,
.product-empty-wide {
  min-height: 120px;
}

.empty-state-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
  gap: 8px;
}

.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip,
.filter-export {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 650;
}

.filter-chip:hover,
.filter-export:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.filter-chip.active {
  border-color: #bed8fb;
  background: var(--primary-soft);
  color: var(--primary);
}

.filter-result {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 12px;
}

.status-strip-main {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.status-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.btn-danger-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
}

.btn-danger-quiet:hover {
  border-color: #efb5ba;
  background: var(--danger-soft);
  color: #a72d37;
}

.store-list {
  display: grid;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.store-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) minmax(120px, 0.55fr) minmax(140px, 0.6fr) auto;
  align-items: center;
  min-height: 66px;
  padding: 10px 14px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.store-row:last-child {
  border-bottom: 0;
}

.store-row:hover {
  background: var(--surface-subtle);
}

.store-identity {
  display: grid;
  min-width: 0;
}

.store-identity strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.store-identity span,
.cell-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.search-results {
  max-height: 360px;
  overflow: auto;
}

.store-order-preview-row > td {
  padding: 0;
  background: var(--surface-subtle);
}

.store-order-preview {
  max-height: 360px;
  padding: 14px 16px;
  overflow: auto;
}

.store-order-preview-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.45fr);
  min-height: 54px;
  padding: 9px 10px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.store-order-preview-item > span {
  display: grid;
}

.store-order-preview-item > span:last-child {
  text-align: right;
}

.inbound-shipment-evidence {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  min-width: 0;
  gap: 8px;
}

.inbound-shipment-evidence > * {
  display: grid;
  gap: 2px;
}

.inbound-shipment-evidence span {
  color: var(--text-secondary);
  font-size: 12px;
}

.ds-inbound-shipment {
  padding: 12px 14px;
}

.tc-copy-value,
.sku-copy-value,
.sku-value,
.erp-order-value,
.platform-order-value,
.tracking-value {
  overflow-wrap: anywhere;
}

.copy-tc,
.query-tc,
.select-family-tcs,
.family-sku-search-btn,
.move-sku,
.sku-row-action,
.pending-stop,
.unbind-store {
  flex: 0 0 auto;
}

.finance-note {
  color: var(--text-secondary);
  font-size: 12px;
}

.ui-v2-advanced-settings {
  overflow: hidden;
}

.iw-back-link,
.iw-inline-button {
  align-self: flex-start;
}

.iw-loading-line,
.iw-status-badge {
  color: var(--text-secondary);
  font-size: 12px;
}

.iw-status-badge {
  display: inline-flex;
  min-height: 26px;
  padding: 3px 9px;
  align-items: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.iw-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 19. Template compatibility: current production views ---------- */
.ds-dashboard,
.domestic-inbound-page,
.zero-sales-page,
.inventory-priority,
.family-detail-table-panel,
.product-table-panel,
.product-sales-table,
.product-filter-bar,
.product-toolbar,
.product-wizard,
.create-product-panel,
.onboarding-panel,
.shared-import-panel,
.order-reference-split,
.zero-sales-summary,
.zero-sales-family-metrics,
.iw-upload-card,
.iw-submit-card,
.iw-view-frame,
.iw-view-process,
.iw-check-frame {
  min-width: 0;
}

.assign-bar,
.family-list-toolbar,
.shared-family-toolbar,
.family-context-line,
.family-subnav,
.order-pagination,
.inventory-detail-title,
.top-owner-switch,
.quick-action {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.family-list-toolbar,
.shared-family-toolbar,
.family-context-line,
.order-pagination,
.inventory-detail-title,
.top-owner-switch {
  justify-content: space-between;
}

.family-sku-picker,
.sku-create-form,
.unassigned-form {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.family-sku-query,
.family-sku-results,
.wizard-results,
.wizard-sku,
.sku-column,
.spec-column,
.current-family-member,
.family-sku-choice,
.inbound-mini,
.group-head {
  min-width: 0;
}

.family-sku-results,
.wizard-results {
  max-height: 360px;
  overflow: auto;
  overscroll-behavior: contain;
}

.family-remove-btn {
  color: var(--danger);
}

.family-remove-btn:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.metric-card-static {
  cursor: default;
}

.secondary {
  color: var(--text-secondary);
}

.status {
  font-weight: 700;
}

.tc-select {
  accent-color: var(--primary);
}

.product-placeholder {
  display: grid;
  min-height: 180px;
  padding: 28px;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  text-align: center;
}

.iw-upload-card,
.iw-submit-card,
.iw-view-frame,
.iw-view-process,
.iw-check-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.iw-view-frame,
.iw-check-frame {
  overflow: auto;
}

/* ---------- 20. Motion and desktop adaptation ---------- */
@keyframes ds-spin {
  to { transform: rotate(360deg); }
}

@keyframes ds-pulse {
  0%, 100% { opacity: 0.56; }
  50% { opacity: 1; }
}

@keyframes ds-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ds-toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-6px); }
}

@media (max-width: 1480px) {
  :root {
    --sidebar-width: 208px;
  }

  .content {
    width: calc(100% - 32px);
    padding-top: 18px;
  }

  .topbar,
  .page-header {
    padding-inline: 16px;
  }

  .page-help-button,
  .data-freshness span:last-child {
    display: none;
  }

  .dashboard-evidence-grid,
  .analysis-main-grid,
  .product-visual-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto;
    animation-duration: 1ms;
    animation-iteration-count: 1;
    transition-duration: 1ms;
    transition-delay: 0s;
  }
}

/* Visibility utilities stay last so component display rules cannot revive an
   intentional hidden/empty/loading state. */
[hidden],
.hidden {
  display: none;
}
