:root {
  --ink: #17212b;
  --muted: #687789;
  --soft: #8d99a8;
  --line: #d9e1e8;
  --line-strong: #c6d0d9;
  --page: #f3f6f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --nav: #1b252e;
  --nav-active: #304047;
  --green: #19725e;
  --green-soft: #e7f3ef;
  --blue: #326bda;
  --blue-soft: #eaf0fb;
  --purple: #7b61a7;
  --orange: #b86c0b;
  --red: #c34e5b;
  --red-soft: #faeaec;
  --yellow: #a86a13;
  --yellow-soft: #fff1d9;
  --tiktok: #293944;
  --youtube: #d55656;
  --instagram: #bc4c92;
  --shadow: 0 16px 36px rgba(35, 52, 62, 0.14);
  --radius: 6px;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, monospace;
  --sans: "Avenir Next", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(50, 107, 218, 0.32);
  outline-offset: 2px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

.skip-link,
.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;
}

.skip-link:focus {
  width: auto;
  height: auto;
  margin: 10px;
  padding: 10px 14px;
  clip: auto;
  z-index: 100;
  color: white;
  background: var(--ink);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  color: #dfe7e9;
  background: var(--nav);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #17362f;
  background: #acd8cc;
  font-size: 11px;
  font-weight: 800;
}

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

.brand strong {
  color: white;
  font-size: 14px;
}

.brand div > span {
  margin-top: 1px;
  color: #7f929a;
  font-size: 11px;
  font-family: var(--mono);
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-top: 26px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 11px;
  border: 0;
  border-radius: 5px;
  color: #9eacb3;
  background: transparent;
  text-align: left;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.055);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item.is-active {
  color: white;
  background: var(--nav-active);
}

.nav-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  font: 9px var(--mono);
}

.nav-item.is-active .nav-index {
  color: #b7e0d6;
  border-color: #5b887f;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  gap: 9px;
  padding: 16px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-foot strong,
.sidebar-foot span {
  display: block;
}

.sidebar-foot strong {
  color: #cbd6d9;
  font-size: 11px;
  font-weight: 600;
}

.sidebar-foot div > span {
  margin-top: 3px;
  color: #75868d;
  font-size: 10px;
}

.health-dot {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: #76d4b9;
  box-shadow: 0 0 0 3px rgba(118, 212, 185, 0.1);
}

.main {
  min-width: 0;
  padding: 28px 28px 56px;
}

.topbar {
  max-width: 1640px;
  margin: 0 auto 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 3px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 760;
}

h2 {
  margin-bottom: 3px;
  font-size: 19px;
  line-height: 1.3;
  font-weight: 730;
}

h3 {
  font-size: 15px;
}

.view-description,
.section-heading p,
.compact-heading p {
  color: var(--muted);
}

.view-description {
  margin-bottom: 0;
}

.snapshot {
  display: grid;
  justify-items: end;
  gap: 1px;
  color: var(--muted);
  font-size: 11px;
}

.snapshot strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

.text-button {
  padding: 3px 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.truth-banner {
  max-width: 1640px;
  min-height: 46px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border: 1px solid #c8dfd7;
  border-radius: var(--radius);
  background: #eff7f4;
}

.truth-banner p {
  margin: 0;
  color: #466158;
  font-size: 12px;
}

.truth-label {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: white;
  background: var(--green);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.view {
  display: none;
  max-width: 1640px;
  margin: 0 auto;
}

.view.is-active {
  display: block;
  animation: view-in 180ms ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.metric-strip.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
  min-width: 0;
  min-height: 112px;
  padding: 18px 19px 16px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  display: block;
  min-height: 21px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.metric-value {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font: 700 27px/1.15 var(--mono);
  font-variant-numeric: tabular-nums;
}

.metric-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

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

.metric-note.negative {
  color: var(--red);
}

.panel {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.trend-panel {
  padding-bottom: 12px;
}

.panel-toolbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.segmented {
  display: flex;
  gap: 7px;
}

.segment,
.metric-button {
  min-height: 34px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: #43515f;
  background: white;
  font-size: 12px;
  font-weight: 650;
  transition: color 180ms ease, border 180ms ease, background 180ms ease, transform 180ms ease;
}

.segment:hover,
.metric-button:hover {
  border-color: #90a7b6;
}

.segment:active,
.metric-button:active {
  transform: translateY(1px);
}

.segment.is-active {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.metric-button.is-active {
  color: var(--green);
  border-color: #7db1a2;
  background: var(--green-soft);
}

.compact .segment {
  padding: 0 12px;
}

.trend-summary {
  display: grid;
  grid-template-columns: 160px 150px minmax(280px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 16px 18px 4px;
}

.trend-summary div {
  min-width: 0;
}

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

.trend-summary strong {
  font-family: var(--mono);
  font-size: 22px;
}

.trend-summary div:last-child strong {
  font-family: var(--sans);
  font-size: 15px;
}

.trend-summary span {
  color: var(--muted);
  font-size: 11px;
}

.stacked-chart {
  height: 296px;
  display: flex;
  align-items: flex-end;
  gap: clamp(14px, 4vw, 62px);
  padding: 28px 40px 26px;
  border-bottom: 1px solid var(--line);
}

.chart-column {
  position: relative;
  flex: 1 1 0;
  min-width: 34px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
}

.chart-bar {
  position: relative;
  width: min(66px, 100%);
  min-height: 3px;
  margin: 0 auto;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  transition: transform 180ms ease, filter 180ms ease;
}

.chart-column:hover .chart-bar {
  transform: translateY(-2px);
  filter: brightness(0.97);
}

.chart-segment {
  min-height: 2px;
}

.chart-total {
  position: absolute;
  bottom: calc(var(--bar-height) + 7px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font: 700 10px var(--mono);
}

.chart-date {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  white-space: nowrap;
  font: 10px var(--mono);
}

.chart-tooltip,
.funnel-tooltip {
  position: fixed;
  z-index: 50;
  width: 250px;
  padding: 12px;
  color: white;
  background: #14232d;
  border-radius: 5px;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 130ms ease, transform 130ms ease;
}

.chart-tooltip.is-visible,
.funnel-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip strong {
  font-family: var(--mono);
  font-size: 12px;
}

.tooltip-total {
  margin: 3px 0 8px;
  color: #d7e3e8;
  font-size: 11px;
}

.tooltip-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  font-size: 10px;
}

.tooltip-swatch {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 18px 0;
  color: var(--muted);
  font-size: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-item i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.section-heading {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading p {
  margin-bottom: 0;
  font-size: 11px;
}

.compact-heading {
  min-height: 64px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-control input,
.heading-actions select,
.analysis-toolbar select,
.analysis-toolbar input,
#quality-range,
#case-label-filter,
#case-side-filter,
#strategy-filter {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: white;
}

.search-control input {
  width: 260px;
  padding: 0 12px;
}

.heading-actions select,
.analysis-toolbar select,
#case-label-filter,
#case-side-filter,
#strategy-filter {
  padding: 0 32px 0 12px;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.data-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 160ms ease;
}

.data-table tbody tr:hover {
  background: #f5f9f8;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.strategy-table {
  min-width: 1320px;
}

.strategy-cell {
  min-width: 260px;
}

.strategy-cell strong,
.strategy-cell span {
  display: block;
}

.strategy-cell strong {
  color: var(--ink);
  font-size: 13px;
}

.strategy-cell span {
  max-width: 320px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
}

.status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-running {
  color: var(--green);
  background: var(--green-soft);
}

.status-attention {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.status-paused {
  color: #71818e;
  background: #edf1f3;
}

.capability-pair,
.quantity-pair {
  display: grid;
  gap: 2px;
  white-space: nowrap;
}

.capability-pair span,
.quantity-pair span {
  color: var(--muted);
  font-size: 10px;
}

.capability-pair strong,
.quantity-pair strong {
  font-family: var(--mono);
  font-size: 12px;
}

.mini-progress {
  width: 94px;
  height: 4px;
  margin-top: 5px;
  border-radius: 2px;
  background: #e2e8ec;
  overflow: hidden;
}

.mini-progress i {
  display: block;
  height: 100%;
  background: var(--green);
}

.quality-cell {
  min-width: 112px;
}

.quality-cell strong {
  font-family: var(--mono);
}

.quality-cell span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.quality-cell.is-warning strong {
  color: var(--yellow);
}

.link-button {
  padding: 5px 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
}

.table-foot,
.pagination {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.analysis-toolbar {
  min-height: 70px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.analysis-toolbar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.analysis-toolbar label:first-child select {
  width: min(460px, 45vw);
}

.analysis-toolbar select {
  min-width: 170px;
}

.toolbar-note {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.tag-real {
  color: var(--green);
  background: var(--green-soft);
}

.tag-derived {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.funnel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr);
  gap: 16px;
}

.funnel-panel,
.loss-panel {
  min-height: 480px;
}

.funnel-basis {
  color: var(--muted);
  font-size: 10px;
}

.funnel-chart {
  position: relative;
  min-height: 400px;
  padding: 26px 28px 30px;
  display: grid;
  align-content: center;
  gap: 0;
}

.funnel-stage {
  position: relative;
  min-height: 58px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font: inherit;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, calc(50% + var(--bottom-half)) 100%, calc(50% - var(--bottom-half)) 100%);
  transition: transform 180ms ease, filter 180ms ease;
}

.funnel-stage:hover {
  z-index: 2;
  transform: scale(1.012);
  filter: brightness(1.04);
}

.funnel-stage:focus-visible,
.funnel-stage.is-selected {
  z-index: 3;
  outline: 3px solid rgba(38, 112, 255, 0.32);
  outline-offset: 3px;
  filter: brightness(1.08);
}

.funnel-stage:nth-child(1) { background: #2e5d70; }
.funnel-stage:nth-child(2) { background: #296979; }
.funnel-stage:nth-child(3) { background: #26766f; }
.funnel-stage:nth-child(4) { background: #218163; }
.funnel-stage:nth-child(5) { background: #1d765e; }
.funnel-stage:nth-child(6) { background: #17674f; }

.funnel-stage-content {
  width: min(360px, 80%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.funnel-stage-content strong,
.funnel-stage-content span {
  display: block;
}

.funnel-stage-content strong {
  font-size: 12px;
}

.funnel-stage-content span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 9px;
}

.funnel-stage-value {
  font: 700 17px var(--mono);
}

.funnel-stage-numbers {
  text-align: right;
}

.funnel-stage-numbers span {
  margin-top: 2px;
}

.funnel-stage-detail {
  padding: 20px;
}

.stage-detail-head,
.stage-case-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.stage-detail-head h2 {
  margin: 3px 0 4px;
  font-size: 20px;
}

.stage-detail-head p,
.stage-case-heading span {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.stage-detail-stats {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.stage-detail-stats > div {
  min-width: 0;
  padding: 13px 14px;
  border-right: 1px solid var(--line);
}

.stage-detail-stats > div:last-child {
  border-right: 0;
}

.stage-detail-stats span,
.stage-detail-stats strong {
  display: block;
}

.stage-detail-stats span {
  color: var(--muted);
  font-size: 10px;
}

.stage-detail-stats strong {
  margin-top: 4px;
  font: 700 17px var(--mono);
}

.stage-case-heading {
  margin: 18px 0 8px;
  align-items: center;
}

.stage-case-heading > div {
  display: grid;
  gap: 2px;
}

.stage-case-list {
  border: 1px solid var(--line);
}

.stage-case {
  min-height: 72px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 78px minmax(250px, 1.5fr) 88px minmax(180px, 0.7fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.stage-case:last-child {
  border-bottom: 0;
}

.stage-case-main {
  display: grid;
  gap: 2px;
}

.stage-case-main strong {
  font-size: 12px;
}

.stage-case-main span,
.stage-case-main a {
  color: var(--muted);
  font-size: 10px;
}

.stage-case-main a {
  width: max-content;
  color: var(--blue);
}

.stage-outcome {
  width: max-content;
  padding: 4px 7px;
  font-size: 10px;
  font-weight: 700;
}

.stage-outcome.is-pass {
  color: var(--green);
  background: var(--green-soft);
}

.stage-outcome.is-loss {
  color: var(--red);
  background: var(--red-soft);
}

.stage-reason {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.stage-reason span {
  color: var(--muted);
  font: 600 10px var(--mono);
}

.stage-reason strong {
  font: 700 12px var(--mono);
}

.dialog-stage-detail {
  padding: 0;
}

.funnel-tooltip strong {
  display: block;
  margin-bottom: 6px;
}

.funnel-tooltip dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  margin: 0;
  color: #d7e3e8;
  font-size: 10px;
}

.funnel-tooltip dt,
.funnel-tooltip dd {
  margin: 0;
}

.funnel-tooltip dd {
  color: white;
  font-family: var(--mono);
}

.loss-list {
  padding: 12px 16px 18px;
}

.loss-row {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.loss-row:last-child {
  border-bottom: 0;
}

.loss-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.loss-row-head strong {
  font-size: 12px;
}

.loss-row-head span {
  color: var(--red);
  font: 700 11px var(--mono);
}

.loss-row p {
  margin: 3px 0 8px;
  color: var(--muted);
  font-size: 10px;
}

.loss-bar {
  height: 5px;
  border-radius: 3px;
  background: #edf1f3;
  overflow: hidden;
}

.loss-bar i {
  display: block;
  height: 100%;
  background: var(--red);
}

.daily-platform-chart,
.infra-chart {
  height: 270px;
  display: flex;
  align-items: flex-end;
  gap: clamp(14px, 4vw, 70px);
  padding: 24px 36px 30px;
  border-bottom: 1px solid var(--line);
}

.platform-column {
  flex: 1 1 0;
  height: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.platform-bar {
  width: min(58px, 80%);
  display: flex;
  flex-direction: column-reverse;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  transition: transform 180ms ease;
}

.platform-column:hover .platform-bar {
  transform: translateY(-2px);
}

.platform-bar i {
  display: block;
}

.platform-total,
.platform-date {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--mono);
}

.platform-total {
  bottom: calc(var(--height) + 7px);
  font-size: 10px;
  font-weight: 700;
}

.platform-date {
  bottom: -21px;
  color: var(--muted);
  font-size: 9px;
}

.daily-table tbody tr {
  cursor: pointer;
}

.daily-table {
  min-width: 980px;
}

.quality-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
}

.distribution-chart {
  padding: 20px 18px 24px;
}

.distribution-bar {
  height: 42px;
  display: flex;
  overflow: hidden;
  border-radius: 5px;
}

.distribution-bar i {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  color: white;
  font: 700 11px var(--mono);
}

.distribution-items {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.distribution-item {
  padding: 12px;
  border-left: 3px solid var(--item-color);
  background: var(--surface-soft);
}

.distribution-item span,
.distribution-item strong {
  display: block;
}

.distribution-item span {
  color: var(--muted);
  font-size: 10px;
}

.distribution-item strong {
  margin-top: 3px;
  font: 700 18px var(--mono);
}

.distribution-item em {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.dual-sample {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.dual-sample > div {
  min-height: 135px;
  padding: 23px 20px;
}

.dual-sample > div + div {
  border-left: 1px solid var(--line);
}

.dual-sample span,
.dual-sample strong,
.dual-sample em {
  display: block;
}

.dual-sample span {
  color: var(--muted);
  font-size: 11px;
}

.dual-sample strong {
  margin-top: 8px;
  font: 700 28px var(--mono);
}

.dual-sample em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.quality-note {
  padding: 16px 20px 20px;
}

.quality-note strong {
  color: var(--yellow);
  font-size: 11px;
}

.quality-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.metric-picker {
  display: flex;
  gap: 6px;
}

.line-chart {
  position: relative;
  height: 300px;
  padding: 18px 24px 24px;
}

.line-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.line-chart .axis-line {
  stroke: #e2e8ec;
  stroke-width: 1;
}

.line-chart .metric-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line-chart .metric-area {
  fill: rgba(25, 114, 94, 0.08);
}

.line-chart .metric-point {
  fill: white;
  stroke: var(--green);
  stroke-width: 3;
}

.line-chart text {
  fill: var(--muted);
  font: 9px var(--mono);
}

.issue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.issue-item {
  min-height: 140px;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.issue-item:last-child {
  border-right: 0;
}

.issue-item strong,
.issue-item span {
  display: block;
}

.issue-item strong {
  margin-top: 8px;
  font: 700 23px var(--mono);
}

.issue-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.issue-rank {
  color: var(--muted);
  font: 10px var(--mono);
}

.case-list {
  display: grid;
}

.case-item {
  display: grid;
  grid-template-columns: 110px minmax(260px, 1.7fr) minmax(150px, 0.7fr) 100px 110px 80px;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.case-item:last-child {
  border-bottom: 0;
}

.case-item:hover {
  background: #f7faf9;
}

.platform {
  display: inline-flex;
  width: fit-content;
  min-width: 74px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: white;
  font-size: 10px;
  font-weight: 700;
}

.platform-youtube { background: var(--youtube); }
.platform-tiktok { background: var(--tiktok); }
.platform-instagram { background: var(--instagram); }

.case-main strong,
.case-main span,
.case-main a {
  display: block;
}

.case-main strong {
  font-size: 12px;
}

.case-main span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.case-main a {
  width: fit-content;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 650;
}

.case-label {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.label-main { color: #205f52; background: #e3f1ec; }
.label-boundary { color: #6a5a8d; background: #efeaf6; }
.label-filter { color: #a3424d; background: #fae9ec; }
.label-pending { color: #966013; background: #fff0d7; }

.case-reason strong,
.case-reason span {
  display: block;
}

.case-reason strong {
  font: 700 10px var(--mono);
}

.case-reason span {
  color: var(--muted);
  font-size: 9px;
}

.case-confidence {
  font: 700 12px var(--mono);
}

.case-side {
  color: var(--muted);
  font-size: 10px;
}

.pagination button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: white;
}

.pagination button:disabled {
  color: #aab4bd;
  cursor: not-allowed;
}

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

.filter-column {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.filter-column:last-child {
  border-right: 0;
}

.filter-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.filter-column header strong {
  font-size: 13px;
}

.filter-column header span {
  color: var(--muted);
  font: 700 12px var(--mono);
}

.filter-reason {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.filter-reason:last-child {
  border-bottom: 0;
}

.filter-reason strong {
  font-family: var(--mono);
}

.detail-dialog,
.methodology-dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: white;
  box-shadow: var(--shadow);
}

.detail-dialog {
  width: min(1480px, calc(100vw - 48px));
  max-width: none;
  height: min(900px, calc(100dvh - 42px));
  border-radius: 7px;
}

.detail-dialog::backdrop,
.methodology-dialog::backdrop {
  background: rgba(20, 33, 43, 0.7);
}

.dialog-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.dialog-header {
  position: relative;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin-bottom: 5px;
  font-size: 25px;
}

.dialog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.back-button {
  position: absolute;
  top: 20px;
  right: 22px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: white;
  font-size: 22px;
}

.dialog-tabs {
  display: flex;
  gap: 28px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
}

.dialog-tab {
  min-height: 52px;
  padding: 0 1px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}

.dialog-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--green);
}

.dialog-content {
  min-height: 0;
  flex: 1;
  padding: 20px 28px 32px;
  overflow: auto;
  background: #fbfcfc;
}

.dialog-section {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  overflow: hidden;
}

.dialog-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.dialog-kpi {
  min-height: 98px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.dialog-kpi:last-child {
  border-right: 0;
}

.dialog-kpi span,
.dialog-kpi strong {
  display: block;
}

.dialog-kpi span {
  color: var(--muted);
  font-size: 10px;
}

.dialog-kpi strong {
  margin-top: 7px;
  font: 700 20px var(--mono);
}

.dialog-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dialog-section-title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-section-title strong,
.dialog-section-title span {
  display: block;
}

.dialog-section-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.unit-list {
  display: grid;
}

.unit-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) 90px 100px 100px 100px 90px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.unit-row:last-child {
  border-bottom: 0;
}

.unit-row strong,
.unit-row span {
  display: block;
}

.unit-row span {
  color: var(--muted);
  font-size: 9px;
}

.methodology-dialog {
  width: min(760px, calc(100vw - 32px));
  border-radius: 7px;
}

.methodology-shell {
  padding-bottom: 8px;
}

.icon-button {
  width: 35px;
  height: 35px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: white;
  font-size: 20px;
}

.methodology-list {
  margin: 0;
  padding: 8px 18px 18px;
}

.methodology-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.methodology-list div:last-child {
  border-bottom: 0;
}

.methodology-list dt {
  font-weight: 700;
}

.methodology-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: 360px;
  padding: 11px 14px;
  color: white;
  background: #18312c;
  border-radius: 5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    padding-inline: 10px;
  }

  .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .brand div,
  .nav-item > span:last-child,
  .sidebar-foot div {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar-foot {
    justify-content: center;
  }

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

  .metric:nth-child(3) {
    border-right: 0;
  }

  .metric:nth-child(-n+3) {
    border-bottom: 1px solid var(--line);
  }

  .metric-strip.five {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .metric-strip.five .metric {
    border-bottom: 0;
  }

  .metric-strip.five .metric:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .funnel-layout,
  .quality-grid {
    grid-template-columns: 1fr;
  }

  .loss-panel,
  .funnel-panel {
    min-height: auto;
  }

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

  .issue-item:nth-child(2) {
    border-right: 0;
  }

  .issue-item:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .case-item {
    grid-template-columns: 90px minmax(260px, 1.6fr) minmax(150px, 0.8fr) 90px 90px;
  }

  .case-side {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    padding: 9px 12px;
  }

  .brand {
    padding: 0 10px 0 0;
    border: 0;
  }

  .side-nav {
    display: flex;
    margin: 0;
    overflow-x: auto;
  }

  .nav-item {
    min-width: 48px;
  }

  .sidebar-foot {
    display: none;
  }

  .main {
    padding: 18px 12px 40px;
  }

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

  .snapshot {
    display: none;
  }

  .truth-banner {
    align-items: flex-start;
  }

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

  .metric,
  .metric-strip.five .metric {
    min-height: 96px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .metric:nth-child(2n),
  .metric-strip.five .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .metric-value {
    font-size: 22px;
  }

  .panel-toolbar,
  .section-heading,
  .analysis-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    overflow-x: auto;
  }

  .trend-summary {
    grid-template-columns: 1fr 1fr;
  }

  .trend-summary > div:last-child {
    grid-column: 1 / -1;
  }

  .stacked-chart {
    gap: 10px;
    padding-inline: 15px;
  }

  .chart-bar {
    width: 36px;
  }

  .search-control input {
    width: 100%;
  }

  .heading-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .analysis-toolbar label:first-child select,
  .analysis-toolbar select {
    width: 100%;
  }

  .toolbar-note {
    margin-left: 0;
  }

  .quality-grid,
  .filter-columns {
    grid-template-columns: 1fr;
  }

  .distribution-items,
  .issue-grid {
    grid-template-columns: 1fr 1fr;
  }

  .funnel-chart {
    min-height: 360px;
    padding-inline: 10px;
  }

  .funnel-stage {
    min-height: 54px;
  }

  .funnel-stage-content {
    width: 84%;
    gap: 8px;
  }

  .funnel-stage-content strong {
    font-size: 10px;
  }

  .funnel-stage-value {
    font-size: 14px;
  }

  .stage-detail-head,
  .stage-case-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .stage-detail-stats > div {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .stage-detail-stats > div:nth-child(2n) {
    border-right: 0;
  }

  .stage-detail-stats > div:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .stage-case {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .stage-outcome,
  .stage-reason {
    grid-column: 2;
    justify-items: start;
  }

  .filter-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-picker {
    overflow-x: auto;
  }

  .case-item {
    grid-template-columns: 78px minmax(0, 1fr) 90px;
    align-items: start;
  }

  .case-reason,
  .case-side,
  .case-confidence {
    display: none;
  }

  .detail-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .dialog-header {
    padding-inline: 18px;
  }

  .dialog-tabs {
    gap: 20px;
    padding-inline: 18px;
    overflow-x: auto;
  }

  .dialog-content {
    padding: 14px 14px 24px;
  }

  .dialog-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .dialog-kpi {
    border-bottom: 1px solid var(--line);
  }

  .dialog-two-column {
    grid-template-columns: 1fr;
  }

  .unit-row {
    grid-template-columns: minmax(0, 1fr) 70px 70px;
  }

  .unit-row > :nth-child(n+4) {
    display: none;
  }
}
