:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647084;
  --line: #dfe4ea;
  --blue: #2563eb;
  --green: #0f8f6f;
  --amber: #b7791f;
  --red: #c2413f;
  --violet: #6d5bd0;
  --shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #111827;
  color: #f8fafc;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  color: #dbeafe;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: #aeb7c4;
  font-size: 13px;
  margin-top: 2px;
}

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

.nav-btn,
.ghost-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.nav-btn {
  height: 42px;
  padding: 0 12px;
  text-align: left;
  color: #dbe4ef;
  background: transparent;
}

.nav-btn:hover,
.nav-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.source-block {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  display: grid;
  gap: 7px;
}

.source-block span,
.source-block small {
  color: #aeb7c4;
  font-size: 12px;
}

.source-block strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

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

.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.2;
}

.ghost-btn {
  height: 36px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.panel,
.table-shell,
.detail-panel,
.quality-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 92px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.metric-note {
  color: var(--muted);
  font-size: 12px;
}

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

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel h3 {
  font-size: 16px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: center;
  min-height: 30px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  background: #edf1f6;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

.bar-fill.green {
  background: var(--green);
}

.bar-fill.amber {
  background: var(--amber);
}

.bar-fill.red {
  background: var(--red);
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 140px 170px 200px;
  gap: 10px;
  margin-bottom: 12px;
}

.filters input,
.filters select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  min-width: 0;
}

.quick-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.quick-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.quick-btn:hover,
.quick-btn.active {
  color: #ffffff;
  background: #1f4f8a;
  border-color: #1f4f8a;
}

.quick-btn b {
  min-width: 24px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
}

.quick-btn:hover b,
.quick-btn.active b {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.table-shell {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
  color: #465366;
  font-size: 12px;
  font-weight: 700;
}

tbody tr[data-id] {
  cursor: pointer;
}

tbody tr[data-id]:hover {
  background: #f8fbff;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  height: 96px;
}

.sku {
  font-weight: 800;
  white-space: nowrap;
}

.product-name {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.search-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: #334155;
  white-space: nowrap;
}

.task-status {
  min-width: 86px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 8px;
}

.status-text {
  max-width: 360px;
  color: #425066;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.p0 {
  color: #ffffff;
  background: var(--red);
}

.p1 {
  color: #ffffff;
  background: var(--amber);
}

.p2 {
  color: #ffffff;
  background: var(--blue);
}

.p3 {
  color: #ffffff;
  background: #64748b;
}

.pill.ok {
  color: #ffffff;
  background: var(--green);
}

.action {
  color: #0f3d71;
  font-weight: 800;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.detail-panel {
  padding: 16px;
  position: sticky;
  top: 18px;
  min-height: 360px;
}

.detail-panel h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.detail-panel h4 {
  margin: 16px 0 10px;
  font-size: 14px;
}

.detail-panel p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.search-card {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.search-card div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-card span {
  color: var(--muted);
  font-size: 12px;
}

.search-card strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.copy-btn {
  height: 28px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #eff6ff;
  color: #1d4ed8;
  cursor: pointer;
}

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

.detail-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 68px;
}

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

.detail-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.flag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.flag {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #334195;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.sparkline {
  height: 88px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 7px;
  padding: 10px 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.spark-col {
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 4px;
  min-width: 0;
}

.spark-col span {
  display: block;
  width: 100%;
  max-width: 22px;
  border-radius: 4px 4px 0 0;
  background: var(--blue);
}

.spark-col small {
  color: var(--muted);
  font-size: 10px;
}

.mini-table {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.mini-table div {
  display: grid;
  grid-template-columns: 68px 1fr 72px;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

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

.mini-table em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

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

.store-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.store-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 116px;
}

.store-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 15px;
}

.store-metrics {
  display: grid;
  gap: 7px;
}

.store-metrics span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.store-metrics b {
  color: var(--ink);
}

.quality-card {
  padding: 14px;
  min-height: 104px;
}

.quality-card strong {
  display: block;
  font-size: 26px;
}

.quality-card span,
.quality-card p {
  color: var(--muted);
  font-size: 13px;
}

.quality-card p {
  margin: 8px 0 0;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

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

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

  .sidebar {
    min-height: auto;
  }

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

  .nav-btn {
    text-align: center;
  }

  .workspace {
    padding: 16px;
  }

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

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

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

@media (max-width: 520px) {
  .metric-grid,
  .store-grid,
  .quality-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 88px minmax(0, 1fr) 38px;
  }
}
