.xhs-ui {
  --xhs-red: #e64655;
  --xhs-red-soft: #fff0f2;
  --cyan: #0b8192;
  --cyan-soft: #e9f7f8;
  --indigo: #5967d9;
  --indigo-soft: #eef0ff;
  --ink: #253047;
}

.xhs-ui.theme-dark {
  --xhs-red: #ff7180;
  --xhs-red-soft: #44262d;
  --cyan: #53c5d0;
  --cyan-soft: #203b41;
  --indigo: #9aa5ff;
  --indigo-soft: #2c3150;
  --ink: #edf1f7;
}

.xhs-ui .brand-mark {
  position: relative;
  overflow: hidden;
  background: var(--xhs-red);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--xhs-red) 24%, transparent);
}

.xhs-ui .brand-mark::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: -8px;
  width: 22px;
  height: 22px;
  border: 5px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.xhs-ui .icon-button [data-lucide],
.xhs-ui .global-search [data-lucide],
.xhs-ui .period-switch [data-lucide],
.xhs-ui .scope-switch [data-lucide],
.xhs-ui .user-menu [data-lucide],
.xhs-ui .nav-search-icon [data-lucide] {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
}

.xhs-ui .nav-icon [data-lucide] {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.period-switch,
.scope-switch,
.live-status {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  white-space: nowrap;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.period-switch:hover,
.scope-switch:hover,
.live-status:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.scope-switch {
  max-width: 175px;
}

.scope-switch span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-status {
  gap: 6px;
  border-color: color-mix(in srgb, var(--success) 18%, var(--line));
  background: var(--success-soft);
  color: var(--success);
}

.live-status strong {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 13%, transparent);
  animation: livePulse 2.2s infinite;
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.78); opacity: 0.62; }
}

.page-shell {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 14px;
  scrollbar-gutter: stable;
}

.page-shell::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.page-shell::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-3) 35%, transparent);
  background-clip: padding-box;
}

.page-title-row {
  min-height: 54px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 1px 2px 11px;
}

.page-title-copy {
  min-width: 0;
}

.page-title-copy h1 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  font-weight: 720;
  line-height: 1.35;
}

.page-title-copy p {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.55;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.flat-button,
.accent-button,
.ghost-button {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.flat-button:hover,
.ghost-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.accent-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.accent-button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.flat-button:active,
.accent-button:active,
.ghost-button:active {
  transform: scale(0.97);
}

.flat-button [data-lucide],
.accent-button [data-lucide],
.ghost-button [data-lucide] {
  width: 14px;
  height: 14px;
}

.context-bar {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.context-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 10px;
}

.context-label [data-lucide] {
  width: 13px;
  height: 13px;
}

.context-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
}

.context-pill {
  height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10px;
  white-space: nowrap;
}

.context-pill.active {
  border-color: color-mix(in srgb, var(--primary) 18%, var(--line));
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
}

.context-spacer {
  flex: 1;
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 10px;
  white-space: nowrap;
}

.freshness [data-lucide] {
  width: 12px;
  height: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(142px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-card {
  position: relative;
  min-width: 0;
  min-height: 112px;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  transition: transform 180ms var(--ease), border-color 180ms ease, box-shadow 180ms ease;
}

.kpi-card:hover {
  z-index: 1;
  border-color: color-mix(in srgb, var(--primary) 24%, var(--line));
  box-shadow: 0 8px 24px rgba(29, 41, 67, 0.08);
  transform: translateY(-2px);
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--kpi-color, var(--primary));
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  overflow: hidden;
  color: var(--text-2);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-icon {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--kpi-color, var(--primary)) 10%, var(--surface));
  color: var(--kpi-color, var(--primary));
}

.kpi-icon [data-lucide] {
  width: 14px;
  height: 14px;
}

.kpi-value {
  margin-top: 8px;
  color: var(--text);
  font-size: 21px;
  font-weight: 760;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-value small {
  margin-left: 2px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
}

.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  margin-top: 9px;
  color: var(--text-3);
  font-size: 9px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--success);
  font-weight: 650;
}

.delta.down { color: var(--danger); }
.delta.neutral { color: var(--text-3); }

.mini-bar {
  width: 38px;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-3);
}

.mini-bar span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--kpi-color, var(--primary));
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.8fr);
  gap: 10px;
  margin-bottom: 10px;
}

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

.content-grid.three {
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, 0.72fr) minmax(270px, 0.72fr);
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

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

.panel-title {
  min-width: 0;
}

.panel-title strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-title span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-actions,
.inline-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 9px;
}

.legend-key::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--legend-color, var(--primary));
}

.segment-control {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.segment-control button {
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  font-size: 9px;
}

.segment-control button.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

.panel-body {
  min-height: 0;
  padding: 12px;
}

.panel-body.flush {
  padding: 0;
}

.trend-wrap {
  position: relative;
  height: 256px;
}

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

.trend-grid-line {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.trend-axis-label {
  fill: var(--text-3);
  font-size: 8px;
}

.trend-line-spend,
.trend-line-lead {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-line-spend { stroke: var(--primary); }
.trend-line-lead { stroke: var(--success); }
.trend-area-spend { fill: color-mix(in srgb, var(--primary) 9%, transparent); }

.trend-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.insight-list {
  display: flex;
  flex-direction: column;
}

.insight-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
  transition: background-color 150ms ease;
}

.insight-row:last-child { border-bottom: 0; }
.insight-row:hover { background: var(--surface-2); }

.insight-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--icon-bg, var(--warning-soft));
  color: var(--icon-color, var(--warning));
}

.insight-icon [data-lucide] {
  width: 14px;
  height: 14px;
}

.insight-copy {
  min-width: 0;
}

.insight-copy strong,
.insight-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-copy strong {
  color: var(--text);
  font-size: 10px;
  font-weight: 650;
}

.insight-copy span {
  margin-top: 3px;
  color: var(--text-3);
  font-size: 9px;
}

.insight-value {
  text-align: right;
}

.insight-value strong,
.insight-value span {
  display: block;
  font-variant-numeric: tabular-nums;
}

.insight-value strong {
  color: var(--text);
  font-size: 11px;
}

.insight-value span {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 8px;
}

.funnel-rail {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 98px;
}

.funnel-node {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.funnel-node:last-child { border-right: 0; }

.funnel-node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -5px;
  z-index: 1;
  width: 8px;
  height: 8px;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  background: var(--surface);
  transform: translateY(-50%) rotate(45deg);
}

.funnel-node span {
  color: var(--text-3);
  font-size: 9px;
}

.funnel-node strong {
  margin-top: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}

.funnel-node em {
  margin-top: 4px;
  color: var(--success);
  font-size: 8px;
  font-style: normal;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 20px 76px minmax(100px, 1fr) 58px;
  align-items: center;
  gap: 8px;
}

.ranking-index {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 8px;
  font-weight: 700;
}

.ranking-row:nth-child(-n+3) .ranking-index {
  background: var(--primary-soft);
  color: var(--primary);
}

.ranking-name {
  overflow: hidden;
  color: var(--text-2);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-track {
  height: 7px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-3);
}

.ranking-track span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--bar-color, var(--primary));
}

.ranking-value {
  color: var(--text);
  font-size: 10px;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.alert-strip {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 22%, var(--line));
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 10px;
}

.alert-strip [data-lucide] {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.alert-strip strong {
  color: var(--text);
}

.alert-strip span {
  color: var(--text-2);
}

.alert-strip button {
  margin-left: auto;
  padding: 2px 0;
  background: transparent;
  color: var(--warning);
  font-size: 10px;
  font-weight: 650;
}

.filter-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px 7px 0 0;
  background: var(--surface);
}

.filter-search {
  position: relative;
  width: min(300px, 34vw);
  min-width: 200px;
}

.filter-search [data-lucide] {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transform: translateY(-50%);
  pointer-events: none;
}

.filter-search input,
.filter-select {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  font-size: 10px;
}

.filter-search input {
  padding: 0 10px 0 31px;
}

.filter-select {
  width: auto;
  min-width: 100px;
  padding: 0 27px 0 9px;
}

.filter-search input:focus,
.filter-select:focus {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 8%, transparent);
}

.filter-row .spacer {
  flex: 1;
}

.compact-summary {
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}

.compact-summary-item {
  min-width: 130px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-right: 1px solid var(--line);
  color: var(--text-3);
  font-size: 9px;
  white-space: nowrap;
}

.compact-summary-item strong {
  color: var(--text);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.matrix-table-wrap {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 7px 7px;
  background: var(--surface);
}

.matrix-table-scroll {
  width: 100%;
  overflow: auto;
}

.matrix-table {
  width: 100%;
  min-width: 1420px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 9px;
}

.matrix-table th,
.matrix-table td {
  height: 40px;
  padding: 6px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.matrix-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 36px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 650;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 176px;
  background: var(--surface);
  text-align: left;
}

.matrix-table th:first-child {
  z-index: 4;
  background: var(--surface-2);
}

.matrix-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 62%, var(--surface));
}

.matrix-table tbody tr:nth-child(even) td:first-child {
  background: color-mix(in srgb, var(--surface-2) 62%, var(--surface));
}

.matrix-table tbody tr:hover td,
.matrix-table tbody tr:hover td:first-child {
  background: var(--primary-soft);
}

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

.account-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-avatar {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--avatar-bg, var(--primary-soft));
  color: var(--avatar-color, var(--primary));
  font-size: 9px;
  font-weight: 750;
}

.account-copy {
  min-width: 0;
}

.account-copy strong,
.account-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  max-width: 126px;
  color: var(--text);
  font-size: 10px;
}

.account-copy span {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 8px;
}

.number-strong {
  color: var(--text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.number-risk { color: var(--danger); font-weight: 650; }
.number-good { color: var(--success); font-weight: 650; }
.number-warn { color: var(--warning); font-weight: 650; }

.health-pill,
.type-pill,
.level-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 650;
}

.health-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.health-pill.good { background: var(--success-soft); color: var(--success); }
.health-pill.warn { background: var(--warning-soft); color: var(--warning); }
.health-pill.risk { background: var(--danger-soft); color: var(--danger); }
.health-pill.quiet { background: var(--surface-3); color: var(--text-3); }
.type-pill { background: var(--primary-soft); color: var(--primary); }
.type-pill.simple { background: var(--cyan-soft); color: var(--cyan); }
.level-pill { background: var(--surface-3); color: var(--text-2); }

.table-footbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-top: 0;
  background: var(--surface);
  color: var(--text-3);
  font-size: 9px;
}

.pager-mini {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pager-mini button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 9px;
}

.pager-mini button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.hierarchy-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.hierarchy-tab {
  position: relative;
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 15px;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  white-space: nowrap;
}

.hierarchy-tab.active {
  color: var(--primary);
  font-weight: 650;
}

.hierarchy-tab.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--primary);
}

.hierarchy-tab span {
  min-width: 18px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 8px;
}

.hierarchy-tab.active span {
  background: var(--primary-soft);
  color: var(--primary);
}

.native-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--surface);
}

.native-kpi {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.native-kpi:last-child { border-right: 0; }
.native-kpi span { color: var(--text-3); font-size: 8px; }
.native-kpi strong { display: block; margin-top: 5px; color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.native-kpi em { margin-left: 5px; color: var(--success); font-size: 8px; font-style: normal; font-weight: 600; }
.native-kpi em.down { color: var(--danger); }

.delivery-table {
  min-width: 1680px;
}

.campaign-name {
  max-width: 210px;
  overflow: hidden;
  color: var(--text);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-id {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 8px;
  font-weight: 400;
}

.creative-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.8fr);
  gap: 10px;
  margin-bottom: 10px;
}

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

.creative-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 180ms var(--ease), border-color 180ms ease, box-shadow 180ms ease;
}

.creative-card:hover {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
  box-shadow: 0 10px 26px rgba(29, 41, 67, 0.1);
  transform: translateY(-2px);
}

.creative-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-3);
}

.creative-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 280ms var(--ease);
}

.creative-card:hover .creative-thumb img { transform: scale(1.035); }

.creative-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(20, 27, 40, 0.72);
  color: #fff;
  font-size: 8px;
  backdrop-filter: blur(4px);
}

.creative-score {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: color-mix(in srgb, var(--success) 86%, transparent);
  color: #fff;
  font-size: 9px;
  font-weight: 750;
}

.creative-content { padding: 10px; }

.creative-name {
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creative-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 5px;
  color: var(--text-3);
  font-size: 8px;
}

.creative-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.creative-metric {
  min-width: 0;
  border-right: 1px solid var(--line);
  text-align: center;
}

.creative-metric:last-child { border-right: 0; }
.creative-metric span { display: block; color: var(--text-3); font-size: 7px; }
.creative-metric strong { display: block; margin-top: 3px; color: var(--text); font-size: 10px; font-variant-numeric: tabular-nums; }

.quadrant {
  position: relative;
  height: 278px;
  overflow: hidden;
  border-radius: 5px;
  background:
    linear-gradient(to right, transparent calc(50% - 0.5px), var(--line) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), var(--line) 50%, transparent calc(50% + 0.5px)),
    var(--surface-2);
}

.quadrant-label {
  position: absolute;
  color: var(--text-3);
  font-size: 8px;
}

.quadrant-label.tl { top: 8px; left: 9px; }
.quadrant-label.tr { top: 8px; right: 9px; }
.quadrant-label.bl { bottom: 8px; left: 9px; }
.quadrant-label.br { right: 9px; bottom: 8px; }

.bubble {
  position: absolute;
  width: var(--size, 32px);
  height: var(--size, 32px);
  display: grid;
  place-items: center;
  border: 2px solid color-mix(in srgb, var(--bubble-color, var(--primary)) 72%, #fff);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bubble-color, var(--primary)) 80%, transparent);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--bubble-color, var(--primary)) 22%, transparent);
  transform: translate(-50%, 50%);
}

.bubble:hover { z-index: 2; transform: translate(-50%, 50%) scale(1.1); }

.heatmap-wrap {
  overflow: auto;
  padding: 2px;
}

.heatmap {
  min-width: 920px;
  display: grid;
  grid-template-columns: 92px repeat(12, minmax(56px, 1fr));
  gap: 4px;
}

.heat-cell,
.heat-head,
.heat-city {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 8px;
}

.heat-head {
  color: var(--text-3);
  font-weight: 600;
}

.heat-city {
  justify-content: flex-start;
  padding-left: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 9px;
  font-weight: 650;
}

.heat-cell {
  position: relative;
  background: color-mix(in srgb, var(--heat-color, var(--primary)) var(--heat, 12%), var(--surface));
  color: var(--text);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.heat-cell:hover {
  z-index: 1;
  box-shadow: 0 6px 16px rgba(22, 32, 52, 0.14);
  transform: scale(1.08);
}

.time-bars {
  height: 230px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 14px 4px 0;
  border-bottom: 1px solid var(--line);
}

.time-bar {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.time-bar-stack {
  width: 72%;
  min-width: 9px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  border-radius: 4px 4px 1px 1px;
  background: var(--surface-3);
}

.time-bar-stack span {
  display: block;
  background: var(--primary);
}

.time-bar-stack em {
  display: block;
  background: var(--success);
}

.time-bar label {
  color: var(--text-3);
  font-size: 7px;
}

.funnel-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.funnel-stage {
  min-height: 47px;
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) 74px 58px;
  align-items: center;
  gap: 9px;
}

.funnel-stage-name {
  color: var(--text-2);
  font-size: 9px;
}

.funnel-stage-track {
  height: 27px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface-3);
}

.funnel-stage-track span {
  height: 100%;
  min-width: 8px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  border-radius: inherit;
  background: var(--stage-color, var(--primary));
  color: #fff;
  font-size: 8px;
  font-weight: 650;
}

.funnel-stage strong {
  color: var(--text);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.funnel-stage em {
  color: var(--text-3);
  font-size: 8px;
  font-style: normal;
  text-align: right;
}

.agent-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) repeat(4, 60px) 74px;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.agent-row:last-child { border-bottom: 0; }
.agent-row:hover { background: var(--surface-2); }

.agent-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.agent-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--avatar-bg, var(--primary-soft));
  color: var(--avatar-color, var(--primary));
  font-size: 9px;
  font-weight: 700;
}

.agent-profile strong,
.agent-profile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-profile strong { color: var(--text); font-size: 9px; }
.agent-profile span { margin-top: 2px; color: var(--text-3); font-size: 8px; }

.agent-stat {
  color: var(--text-2);
  font-size: 9px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.progress-line {
  height: 5px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface-3);
}

.progress-line span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--progress-color, var(--success));
}

.roi-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 22px;
  padding: 14px;
}

.roi-node {
  position: relative;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  text-align: center;
}

.roi-node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  width: 22px;
  border-top: 1px dashed var(--line-strong);
}

.roi-node:not(:last-child)::before {
  content: "";
  position: absolute;
  top: calc(50% - 3px);
  left: calc(100% + 17px);
  z-index: 1;
  width: 6px;
  height: 6px;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  transform: rotate(45deg);
}

.roi-node span { color: var(--text-3); font-size: 8px; }
.roi-node strong { margin-top: 7px; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }
.roi-node em { margin-top: 4px; color: var(--success); font-size: 8px; font-style: normal; }

.donut-wrap {
  min-height: 244px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.donut {
  position: relative;
  width: 154px;
  height: 154px;
  flex: 0 0 154px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0 43%, var(--success) 43% 69%, var(--warning) 69% 86%, var(--xhs-red) 86% 96%, var(--line) 96% 100%);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  background: var(--surface);
}

.donut-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-center strong { color: var(--text); font-size: 20px; }
.donut-center span { margin-top: 3px; color: var(--text-3); font-size: 8px; }

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.donut-legend-row {
  display: grid;
  grid-template-columns: 8px 64px 52px;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-size: 9px;
}

.donut-legend-row i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--color);
}

.donut-legend-row strong {
  color: var(--text);
  font-size: 9px;
  text-align: right;
}

.budget-list {
  display: flex;
  flex-direction: column;
}

.budget-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) 90px 90px minmax(120px, 1fr) 64px;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--line);
}

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

.budget-copy strong,
.budget-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-copy strong { color: var(--text); font-size: 9px; }
.budget-copy span { margin-top: 2px; color: var(--text-3); font-size: 8px; }
.budget-number { color: var(--text-2); font-size: 9px; text-align: right; font-variant-numeric: tabular-nums; }
.runway { color: var(--text); font-size: 9px; font-weight: 650; text-align: right; }
.runway.risk { color: var(--danger); }

.finance-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.finance-stat {
  min-height: 78px;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.finance-stat:last-child { border-right: 0; }
.finance-stat span { color: var(--text-3); font-size: 8px; }
.finance-stat strong { display: block; margin-top: 7px; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }
.finance-stat em { display: block; margin-top: 4px; color: var(--success); font-size: 8px; font-style: normal; }
.finance-stat em.risk { color: var(--danger); }

.anomaly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
}

.anomaly-table th,
.anomaly-table td {
  height: 40px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  text-align: left;
  white-space: nowrap;
}

.anomaly-table th {
  background: var(--surface-2);
  color: var(--text-3);
  font-weight: 600;
}

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

.severity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 650;
}

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

.severity.high { color: var(--danger); }
.severity.medium { color: var(--warning); }
.severity.low { color: var(--primary); }

.empty-state {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  text-align: center;
}

.empty-state [data-lucide] {
  width: 34px;
  height: 34px;
  opacity: 0.45;
}

.empty-state strong { margin-top: 10px; color: var(--text-2); font-size: 11px; }
.empty-state span { margin-top: 4px; font-size: 9px; }

.popover {
  position: fixed;
  z-index: 80;
  min-width: 230px;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.popover.open { display: block; animation: popIn 150ms var(--ease); }

@keyframes popIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-head {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
}

.popover-list { padding: 5px; }

.popover-item {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: 9px;
  text-align: left;
}

.popover-item:hover { background: var(--surface-2); color: var(--text); }
.popover-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.popover-item [data-lucide] { width: 14px; height: 14px; }
.popover-item span { margin-left: auto; color: var(--text-3); font-size: 8px; }

.drawer-entity-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 750;
}

.xhs-drawer .drawer-head {
  gap: 10px;
}

.drawer-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
}

.drawer-kpi {
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--line);
}

.drawer-kpi:last-child { border-right: 0; }
.drawer-kpi span { color: var(--text-3); font-size: 8px; }
.drawer-kpi strong { display: block; margin-top: 5px; color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }

.drawer-section {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.drawer-section h3 {
  margin: 0;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 10px;
}

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

.drawer-detail {
  min-height: 45px;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.drawer-detail:nth-child(even) { border-right: 0; }
.drawer-detail:nth-last-child(-n+2) { border-bottom: 0; }
.drawer-detail span { color: var(--text-3); font-size: 8px; }
.drawer-detail strong { overflow: hidden; color: var(--text); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.drawer-timeline {
  padding: 4px 10px;
}

.drawer-event {
  position: relative;
  min-height: 58px;
  padding: 9px 0 8px 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-event:last-child { border-bottom: 0; }
.drawer-event::before { content: ""; position: absolute; top: 14px; left: 2px; width: 7px; height: 7px; border: 2px solid var(--event-color, var(--primary)); border-radius: 50%; background: var(--surface); }
.drawer-event::after { content: ""; position: absolute; top: 23px; bottom: -12px; left: 6px; border-left: 1px dashed var(--line-strong); }
.drawer-event:last-child::after { display: none; }
.drawer-event strong { color: var(--text); font-size: 9px; }
.drawer-event span { float: right; color: var(--text-3); font-size: 8px; }
.drawer-event p { margin: 4px 0 0; color: var(--text-3); font-size: 8px; line-height: 1.5; }

@media (max-width: 1480px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .creative-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content-grid.three { grid-template-columns: minmax(0, 1.3fr) minmax(270px, 0.85fr); }
  .content-grid.three > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 1180px) {
  .scope-switch,
  .live-status { display: none; }
  .content-grid,
  .creative-overview { grid-template-columns: 1fr; }
  .creative-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .native-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .native-kpi:nth-child(3) { border-right: 0; }
  .native-kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .funnel-rail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .funnel-node:nth-child(3) { border-right: 0; }
  .funnel-node:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .roi-flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .roi-node::after,
  .roi-node::before { display: none; }
}

@media (max-width: 900px) {
  .period-switch { display: none; }
  .page-shell { padding: 10px; }
  .content-grid.equal,
  .content-grid.three { grid-template-columns: 1fr; }
  .content-grid.three > :last-child { grid-column: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel-stage { grid-template-columns: 80px minmax(0, 1fr) 58px; }
  .funnel-stage em { display: none; }
  .agent-row { grid-template-columns: minmax(130px, 1fr) repeat(2, 56px) 66px; }
  .agent-row > :nth-child(4),
  .agent-row > :nth-child(5) { display: none; }
  .finance-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-stat:nth-child(2) { border-right: 0; }
  .finance-stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .budget-row { grid-template-columns: minmax(120px, 1fr) 72px minmax(100px, 1fr) 54px; }
  .budget-row > :nth-child(3) { display: none; }
}

@media (max-width: 620px) {
  .page-title-row { align-items: stretch; flex-direction: column; }
  .page-actions { width: 100%; overflow-x: auto; }
  .context-bar { align-items: flex-start; flex-direction: column; }
  .context-spacer,
  .freshness { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 96px; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .filter-search { width: 100%; min-width: 0; }
  .filter-select { width: 100%; }
  .filter-row .spacer { display: none; }
  .filter-row .flat-button,
  .filter-row .accent-button { width: 100%; }
  .creative-grid { grid-template-columns: 1fr; }
  .funnel-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel-node:nth-child(3) { border-right: 1px solid var(--line); }
  .funnel-node:nth-child(2n) { border-right: 0; }
  .funnel-node:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .native-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .native-kpi:nth-child(3) { border-right: 1px solid var(--line); }
  .native-kpi:nth-child(2n) { border-right: 0; }
  .native-kpi:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .roi-flow { grid-template-columns: 1fr; gap: 7px; }
  .donut-wrap { align-items: flex-start; flex-direction: column; }
  .donut { align-self: center; }
  .drawer-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-kpi:nth-child(2) { border-right: 0; }
  .drawer-kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .drawer-detail-grid { grid-template-columns: 1fr; }
  .drawer-detail,
  .drawer-detail:nth-child(even) { border-right: 0; }
  .drawer-detail:nth-last-child(2) { border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}
