:root {
  --bg: #f4f7fb;
  --card: #fff;
  --text: #15243d;
  --muted: #667085;
  --line: #e4e9f0;
  --blue: #2563eb;
  --teal: #0d9488;
  --purple: #7c3aed;
  --orange: #f59e0b;
  --red: #e5484d;
  --green: #168f63;
  --shadow: 0 12px 34px rgba(16, 24, 40, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, #e8f6f5 0, transparent 28%), var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
.dashboard {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 48px;
}
.page-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-nav-link {
  text-decoration: none;
  color: #475467;
  font-weight: 780;
  padding: 9px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}
.page-nav-link.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #155ec7, #0f9f8f);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 26px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.13em;
}
h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1.06;
  letter-spacing: -0.04em;
}
.subtitle {
  max-width: 850px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.controls {
  display: flex;
  gap: 12px;
  min-width: 420px;
}
.controls label {
  display: grid;
  gap: 7px;
  flex: 1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.controls select {
  border: 1px solid #d6dce5;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.04);
}
.warning-note {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid #f5d49b;
  background: #fff9ed;
  color: #7a4b00;
  border-radius: 14px;
  padding: 12px 15px;
  margin-bottom: 14px;
  font-size: 12px;
}
.naming-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a5f;
  border-radius: 14px;
  padding: 12px 15px;
  margin: -2px 0 14px;
  font-size: 12px;
  line-height: 1.5;
}
.naming-note strong {
  white-space: nowrap;
}
.kpi-grid {
  display: grid;
  grid-template-columns: 1.15fr repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 5px 18px rgba(16, 24, 40, 0.04);
}
.kpi-card span,
.kpi-card small {
  display: block;
  color: var(--muted);
}
.kpi-card span {
  font-size: 12px;
  font-weight: 800;
}
.kpi-card strong {
  display: block;
  margin: 9px 0 5px;
  font-size: clamp(25px, 2.3vw, 36px);
  letter-spacing: -0.04em;
}
.kpi-card small {
  font-size: 11px;
  line-height: 1.35;
}
.kpi-card.hero {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #155ec7, #0e9f92);
  box-shadow: 0 15px 35px rgba(21, 94, 199, 0.22);
}
.kpi-card.hero span,
.kpi-card.hero small {
  color: rgba(255, 255, 255, 0.82);
}
.kpi-card.protection {
  border-color: #f3d7b4;
  background: linear-gradient(180deg, #fff, #fff9ef);
}
.size-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.size-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-radius: 20px;
  padding: 20px;
  color: #fff;
  box-shadow: var(--shadow);
  min-height: 142px;
}
.size-card.two {
  background: linear-gradient(135deg, #1769d2, #37a7c8);
}
.size-card.three {
  background: linear-gradient(135deg, #0c8f82, #34b28f);
}
.size-card.four {
  background: linear-gradient(135deg, #6c35c7, #a455da);
}
.size-card span,
.size-card small {
  display: block;
  color: rgba(255, 255, 255, 0.82);
}
.size-card span {
  font-weight: 850;
}
.size-card strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 36px;
  letter-spacing: -0.04em;
}
.size-card small {
  font-size: 12px;
}
.size-stats {
  display: grid;
  grid-template-columns: auto auto;
  align-content: center;
  gap: 4px 8px;
  text-align: right;
}
.size-stats b {
  font-size: 18px;
}
.size-stats em {
  font-style: normal;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 19px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.panel-head h2 {
  margin: 0;
  font-size: 19px;
}
.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.chart-box {
  position: relative;
  min-height: 330px;
}
.chart-box.tall {
  min-height: 440px;
}
.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 14px;
}
.view-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: #475467;
  border-radius: 999px;
  padding: 10px 15px;
  font-weight: 820;
  cursor: pointer;
}
.view-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--teal));
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
.mini-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.mini-kpis article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.mini-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}
.mini-kpis strong {
  display: block;
  margin-top: 7px;
  font-size: 21px;
  line-height: 1.25;
}
.table-panel {
  padding-bottom: 14px;
}
.table-wrap {
  overflow: auto;
  border: 1px solid #edf0f4;
  border-radius: 14px;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1000px;
}
th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid #edf0f4;
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #667085;
  font-weight: 850;
}
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4) {
  text-align: left;
}
tbody tr:hover {
  background: #fbfcff;
}
.combo-name {
  font-weight: 780;
  max-width: 520px;
  white-space: normal;
  line-height: 1.35;
}
.rank {
  color: #98a2b3;
  font-weight: 850;
}
.pill {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
}
.pill.fbt {
  background: #e8f4ff;
  color: #155ec7;
}
.pill.bundle {
  background: #eefaf4;
  color: #137a4b;
}
.pill.test {
  background: #fff5dd;
  color: #9a6700;
}
.pill.bad {
  background: #ffeceb;
  color: #b42318;
}
.audit-callout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.audit-callout > div {
  background: #fff;
  border: 1px solid #f0d7bb;
  border-radius: 17px;
  padding: 17px;
}
.audit-callout span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}
.audit-callout strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}
.error-box {
  margin-top: 16px;
  border-radius: 14px;
  background: #fff0ef;
  color: #b42318;
  padding: 14px;
}
footer {
  margin-top: 16px;
  color: #7b8494;
  font-size: 11px;
  line-height: 1.55;
}
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .mini-kpis,
  .audit-callout {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 850px) {
  .dashboard {
    width: min(100% - 24px, 1500px);
    padding-top: 16px;
  }
  .topbar {
    flex-direction: column;
  }
  .controls {
    width: 100%;
    min-width: 0;
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .size-cards {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .warning-note {
    align-items: flex-start;
  }
  .chart-box.tall {
    min-height: 500px;
  }
}
@media (max-width: 560px) {
  .controls {
    flex-direction: column;
  }
  .kpi-grid,
  .mini-kpis,
  .audit-callout {
    grid-template-columns: 1fr;
  }
  .size-card {
    min-height: 130px;
  }
  .panel {
    padding: 14px;
  }
  .page-nav-link {
    font-size: 12px;
  }
  .chart-box {
    min-height: 360px;
  }
}

/* Search and unambiguous multi-product naming */
.search-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.85fr);
  gap: 24px;
  align-items: center;
  margin: 20px 0 14px;
  padding: 20px;
  border: 1px solid #cfe2ef;
  border-radius: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f1f8ff 50%, #eefbf8 100%);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
}
.search-copy h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}
.search-copy p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.search-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.search-actions small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 0 13px;
  border: 1px solid #cbd5e1;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.05);
}
.search-input-wrap:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}
.search-input-wrap > span {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 23px;
  line-height: 1;
  transform: rotate(-15deg);
}
.search-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 12px 0;
  font: inherit;
  font-size: 14px;
}
.search-input-wrap input::placeholder {
  color: #98a2b3;
}
.clear-search {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  color: #475467;
  padding: 11px 14px;
  font-weight: 800;
  cursor: pointer;
}
.clear-search:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}
.search-results {
  margin: 0 0 18px;
  padding: 17px;
  border: 1px solid #dfe7ef;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
}
.search-results-head {
  margin-bottom: 12px;
}
.search-results-head strong,
.search-results-head span {
  display: block;
}
.search-results-head strong {
  font-size: 15px;
}
.search-results-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.search-result-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.search-result-group {
  min-width: 0;
  border: 1px solid #e8edf2;
  border-radius: 15px;
  padding: 12px;
  background: #fbfcfe;
}
.search-result-group h3 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 9px;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.search-result-group h3 span {
  color: #98a2b3;
}
.search-result-list {
  display: grid;
  gap: 7px;
}
.search-result-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #e5eaf0;
  border-radius: 11px;
  background: #fff;
  padding: 10px 11px;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.search-result-item:hover {
  border-color: #9ccfc7;
  transform: translateY(-1px);
}
.search-result-main strong,
.search-result-main small {
  display: block;
}
.search-result-main {
  min-width: 0;
}
.search-result-main strong {
  overflow: hidden;
  color: #24324a;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-main small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-meta {
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}
.search-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.combo-name {
  min-width: 420px;
  max-width: 680px;
  white-space: normal;
}
.combo-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.combo-product-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 7px;
  max-width: 330px;
  padding: 7px 9px;
  border: 1px solid #d8e2ee;
  border-radius: 10px;
  background: #f8fbff;
  color: #23324b;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.35;
  white-space: normal;
}
.combo-product-chip.sku-chip {
  background: #f7f4ff;
  border-color: #ddd3f5;
  color: #51329b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.combo-index {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}
.combo-product-chip.item-2 .combo-index {
  background: #0d9488;
}
.combo-product-chip.item-3 .combo-index {
  background: #7c3aed;
}
.combo-product-chip.item-4 .combo-index {
  background: #f59e0b;
}
.combo-connector {
  color: #98a2b3;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.sku-chip-copy {
  display: grid;
  gap: 2px;
}
.sku-chip-copy small {
  color: #7c6fa4;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 9px;
  font-weight: 600;
}
.anchor-product-name {
  color: #24324a;
  font-weight: 820;
  line-height: 1.35;
}
@media (max-width: 900px) {
  .search-shell,
  .search-result-groups {
    grid-template-columns: 1fr;
  }
  .combo-name {
    min-width: 330px;
  }
}
@media (max-width: 560px) {
  .search-actions {
    grid-template-columns: 1fr;
  }
  .clear-search {
    width: 100%;
  }
}


/* V6: readable one-row SPU ranking */
.spu-analysis-grid {
  grid-template-columns: 1fr;
}
.top-combo-panel {
  overflow: visible;
}
.combo-ranking-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.combo-rank-row {
  position: relative;
  padding: 15px 16px 13px;
  border: 1px solid #e1e8f0;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 5px 16px rgba(16, 24, 40, 0.045);
}
.combo-rank-row:first-child {
  border-color: #b8d5ff;
  background: linear-gradient(135deg, #f7fbff 0%, #eef7ff 100%);
}
.combo-rank-main {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}
.combo-rank-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: #edf3fb;
  color: #34435d;
  font-size: 14px;
  font-weight: 900;
}
.combo-rank-row:first-child .combo-rank-number {
  background: #2563eb;
  color: #fff;
}
.combo-rank-products {
  min-width: 0;
}
.combo-rank-products .combo-chips {
  flex-wrap: nowrap;
  gap: 10px;
}
.combo-rank-products .combo-product-chip {
  max-width: none;
  min-height: 42px;
  flex: 1 1 0;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.35;
}
.combo-rank-products .combo-connector {
  flex: 0 0 auto;
  padding: 0 2px;
  font-size: 9px;
}
.combo-rank-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, auto));
  gap: 8px;
}
.combo-rank-metrics span {
  display: grid;
  gap: 3px;
  min-width: 82px;
  padding: 8px 10px;
  border: 1px solid #e3eaf2;
  border-radius: 11px;
  background: #fff;
  text-align: right;
}
.combo-rank-metrics small {
  color: #7b8494;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.combo-rank-metrics strong {
  color: #17243a;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.combo-rank-progress {
  height: 5px;
  margin: 11px 0 0 56px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}
.combo-rank-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb 0%, #0d9488 100%);
}
.empty-combo-list {
  padding: 32px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: #667085;
  text-align: center;
}
@media (max-width: 1050px) {
  .combo-rank-main {
    grid-template-columns: 38px minmax(0, 1fr);
  }
  .combo-rank-metrics {
    grid-column: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .combo-rank-metrics span {
    text-align: left;
  }
  .combo-rank-progress {
    margin-left: 52px;
  }
}
@media (max-width: 700px) {
  .combo-rank-row {
    padding: 13px;
  }
  .combo-rank-main {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }
  .combo-rank-number {
    width: 32px;
    height: 32px;
  }
  .combo-rank-products .combo-chips {
    flex-direction: column;
    align-items: stretch;
  }
  .combo-rank-products .combo-connector {
    align-self: center;
  }
  .combo-rank-metrics {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }
  .combo-rank-metrics span {
    min-width: 0;
    padding: 7px 8px;
  }
  .combo-rank-progress {
    margin-left: 0;
  }
}
