:root {
  color-scheme: light;
  --ink: #161a23;
  --paper: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --line: #d9dee7;
  --muted: #687385;
  --blue: #1f63ff;
  --green: #079669;
  --orange: #e66d21;
  --violet: #7256df;
  --red: #cf3f35;
  --shadow: 0 18px 50px rgba(26, 36, 55, 0.09);
  --shadow-soft: 0 8px 22px rgba(26, 36, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(22, 26, 35, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(22, 26, 35, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.store-shell {
  min-height: 100vh;
  width: 100%;
  overflow-x: clip;
}

.store-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 74px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

.store-brand,
.store-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.store-brand strong,
.store-brand span {
  display: block;
  overflow-wrap: anywhere;
}

.store-brand span,
.store-actions span,
.store-nav button {
  color: var(--muted);
  font-size: 0.9rem;
}

.store-nav {
  display: flex;
  gap: 6px;
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.store-nav button,
.store-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.store-nav button.active {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.store-actions {
  justify-content: end;
}

.store-actions button {
  border: 1px solid var(--line);
  background: var(--surface);
}

.store-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.store-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.store-hero > div:first-child,
.store-hero-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.store-hero > div:first-child {
  padding: 24px;
}

.store-hero h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
}

.store-hero span {
  color: var(--muted);
}

.store-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.store-trust-row span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.store-hero-card {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 22px;
  background: linear-gradient(135deg, #ffffff, #edf3ff);
}

.store-hero-card strong {
  font-size: 2.3rem;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ink), #2f3c52);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.eyebrow,
.rail-status span,
.top-metrics span,
td span,
.product-category,
.product-card em,
.product-card span,
.sku-chip span,
.field span,
.price-stack span,
.metric-card span,
.metric-card em,
.gate-item span,
.gate-item p,
.gate-item em,
.ops-list span,
.kb-list span,
.supplier-row span,
.risk-list em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #eef2f7;
  font-weight: 800;
}

.nav-item.active {
  border-color: #243044;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.nav-item.active span {
  background: var(--blue);
}

.rail-status {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.rail-status strong {
  display: block;
  font-size: 1.2rem;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(15, 159, 119, 0.12);
}

.workspace {
  min-width: 0;
  padding: 22px;
  overflow-x: clip;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.top-cluster {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.user-chip {
  min-width: 134px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.user-chip span,
.user-chip strong {
  display: block;
}

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

.user-chip strong {
  margin-top: 5px;
  font-size: 0.98rem;
}

.top-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 96px));
  gap: 10px;
}

.top-metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.top-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

.customer-grid,
.ops-grid,
.bi-grid,
.agents-grid {
  display: grid;
  gap: 16px;
}

.customer-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  align-items: start;
}

.wide {
  grid-column: 1 / -1;
}

.ops-grid,
.agents-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.bi-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.supplier-panel,
.risk-panel {
  grid-column: span 2;
}

.section-panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.section-panel {
  padding: 16px;
  min-width: 0;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.good {
  background: rgba(15, 159, 119, 0.12);
  color: #057052;
}

.badge.warn {
  background: rgba(239, 123, 45, 0.16);
  color: #9d440c;
}

.badge.neutral {
  background: #edf1f6;
  color: var(--ink);
}

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

.product-card {
  display: grid;
  gap: 9px;
  min-width: 0;
  min-height: 158px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.product-card:hover,
.product-card.active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.product-card.active {
  border-color: var(--ink);
}

.product-card strong {
  font-size: 1.34rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.product-card em {
  line-height: 1.5;
}

.product-price {
  align-self: end;
  color: var(--ink);
  font-weight: 800;
}

.product-meta {
  font-weight: 700;
}

.accent-green {
  border-top: 4px solid var(--green);
}

.accent-blue {
  border-top: 4px solid var(--blue);
}

.accent-orange {
  border-top: 4px solid var(--orange);
}

.accent-violet {
  border-top: 4px solid var(--violet);
}

.checkout-panel {
  min-height: 100%;
  position: sticky;
  top: 16px;
}

.checkout-summary {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 8px;
  margin-bottom: 12px;
}

.checkout-summary div {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.checkout-summary span,
.checkout-summary strong {
  display: block;
}

.checkout-summary span {
  color: var(--muted);
  font-size: 0.78rem;
}

.checkout-summary strong {
  margin-top: 6px;
  font-size: 1rem;
}

.sku-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.sku-chip {
  min-height: 62px;
  padding: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: left;
}

.sku-chip strong,
.sku-chip span {
  display: block;
}

.sku-chip.active {
  border-color: var(--blue);
  background: rgba(36, 88, 255, 0.08);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(36, 88, 255, 0.12);
}

.field-hint {
  font-size: 0.78rem;
  font-style: normal;
}

.field-hint.good {
  color: var(--green);
}

.field-hint.warn {
  color: var(--orange);
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 0.9rem;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 8px;
  background: #d7d2c6;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(14px);
}

.price-stack {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.price-stack div {
  min-height: 68px;
  padding: 10px;
  border-radius: 8px;
  background: #eef2f7;
}

.price-stack strong {
  display: block;
  margin-top: 7px;
  font-size: 1.15rem;
}

.customer-price-stack {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.customer-price-stack div {
  min-height: 70px;
  padding: 11px;
  border-radius: 8px;
  background: #eef2f7;
}

.customer-price-stack span,
.customer-price-stack strong {
  display: block;
}

.customer-price-stack span {
  color: var(--muted);
  font-size: 0.82rem;
}

.customer-price-stack strong {
  margin-top: 7px;
  font-size: 1.16rem;
}

.positive {
  color: var(--green);
}

.warning {
  color: var(--orange);
}

.primary-action,
.ghost-action,
.order-actions button,
.row-actions button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  font-weight: 800;
}

.primary-action {
  width: 100%;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 10px 24px rgba(31, 99, 255, 0.22);
}

.primary-action.compact {
  width: auto;
  padding: 0 14px;
}

.ghost-action,
.order-actions button,
.row-actions button {
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
}

.ghost-action:hover,
.order-actions button:not(:disabled):hover,
.row-actions button:not(:disabled):hover {
  border-color: var(--blue);
  color: var(--blue);
}

.order-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #202838;
  color: #fff;
  min-width: 0;
}

.order-identity {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.order-identity strong,
.order-identity span {
  overflow-wrap: anywhere;
}

.order-identity span:last-child {
  color: rgba(255, 255, 255, 0.72);
}

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

.order-actions button {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.timeline {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.timeline div {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 0 2px;
}

.timeline div span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

.timeline em {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  background: var(--surface-soft);
}

td strong,
td span {
  display: block;
}

.row-actions {
  white-space: nowrap;
}

.row-actions button {
  min-height: 32px;
  padding: 0 9px;
}

.kb-list,
.ops-list,
.risk-list,
.supplier-list {
  display: grid;
  gap: 10px;
}

.kb-list div,
.ops-list div,
.risk-list div,
.supplier-row {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.bi-grid .metric-card {
  min-height: 132px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

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

.metric-card.ink {
  background: var(--ink);
  color: #fff;
}

.metric-card.ink span,
.metric-card.ink em {
  color: rgba(255, 255, 255, 0.66);
}

.metric-card.green {
  border-top: 4px solid var(--green);
}

.metric-card.orange {
  border-top: 4px solid var(--orange);
}

.metric-card.violet {
  border-top: 4px solid var(--violet);
}

.supplier-row {
  grid-template-columns: minmax(180px, 0.7fr) 1fr 48px;
  align-items: center;
}

.scorebar {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #e5eaf1;
}

.scorebar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.risk-list div {
  grid-template-columns: 52px 130px 1fr;
  align-items: center;
}

.market-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
}

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

.market-cards div {
  min-height: 150px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.market-cards strong {
  font-size: 1.02rem;
}

.market-cards span {
  color: var(--muted);
  line-height: 1.55;
}

.gate-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.gate-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--green) calc(var(--progress) * 100%), var(--line) 0);
  z-index: 0;
  pointer-events: none;
}

.gate-item {
  position: relative;
  z-index: 1;
  min-height: 180px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.gate-item.passed {
  border-color: rgba(15, 159, 119, 0.42);
  background: rgba(15, 159, 119, 0.08);
}

.gate-item.blocked {
  border-color: rgba(216, 74, 58, 0.44);
}

.gate-item em {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 8px;
  background: #edf1f6;
  color: var(--ink);
  font-weight: 800;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

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

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .rail-status {
    min-width: 170px;
  }

  .store-topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .store-nav,
  .store-actions {
    justify-content: start;
    overflow-x: auto;
  }

  .store-hero {
    grid-template-columns: 1fr;
  }

  .customer-grid,
  .ops-grid,
  .agents-grid,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .checkout-panel {
    position: static;
  }

  .product-grid,
  .bi-grid,
  .gate-track,
  .market-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .supplier-panel,
  .risk-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .workspace,
  .rail {
    padding: 14px;
  }

  .store-main {
    padding: 14px;
  }

  .topbar,
  .order-main {
    flex-direction: column;
    align-items: stretch;
  }

  .top-cluster {
    flex-direction: column;
  }

  .user-chip {
    display: none;
  }

  .product-grid,
  .bi-grid,
  .gate-track,
  .market-cards {
    grid-template-columns: 1fr;
  }

  .top-metrics,
  .checkout-summary,
  .customer-price-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .price-stack {
    grid-template-columns: 1fr;
  }

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

  .rail {
    gap: 12px;
  }

  .brand {
    min-width: 150px;
  }

  .nav-item {
    grid-template-columns: 28px max-content;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .shop-panel {
    order: 2;
  }

  .checkout-panel {
    order: 1;
  }

  .order-panel {
    order: 3;
  }

  .product-card {
    min-height: 132px;
  }

  .checkout-summary div,
  .price-stack div,
  .customer-price-stack div {
    min-height: 58px;
    padding: 9px;
  }

  .checkout-summary strong,
  .price-stack strong,
  .customer-price-stack strong {
    font-size: 0.95rem;
  }

  .sku-chip {
    min-height: 56px;
    padding: 8px;
  }

  .switch {
    min-height: 40px;
    padding: 7px 8px;
    font-size: 0.82rem;
  }

  .order-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .supplier-row,
  .risk-list div {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .store-topbar {
    gap: 10px;
    padding: 12px 14px;
  }

  .store-nav {
    width: 100%;
  }

  .store-nav button {
    flex: 1 0 auto;
    padding: 0 9px;
  }

  .store-actions {
    width: 100%;
    justify-content: space-between;
  }

  .store-hero > div:first-child,
  .store-hero-card,
  .section-panel {
    padding: 14px;
  }

  .store-hero h1 {
    font-size: 1.8rem;
  }

  .top-metrics,
  .checkout-summary,
  .customer-price-stack,
  .switch-row,
  .order-actions {
    grid-template-columns: 1fr;
  }

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