:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #17202f;
  --muted: #667085;
  --line: #dbe3ef;
  --blue: #2563eb;
  --cyan: #0891b2;
  --green: #0f9f6e;
  --red: #d04747;
  --amber: #c98212;
  --shadow: 0 18px 48px rgba(31, 42, 68, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 24px 18px;
  color: #f8fbff;
  background: #152033;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #30b3a6;
  font-weight: 800;
}

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

.brand span,
.sync-card span,
.sync-card small {
  color: #a9b7cb;
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: #d9e4f5;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

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

.sync-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sync-card strong,
.sync-card small {
  display: block;
  margin-top: 6px;
}

.app-shell {
  margin-left: 248px;
  padding: 28px;
}

.view {
  display: none;
}

.view.active-view {
  display: block;
}

.topbar,
.toolbar,
.panel-header,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
}

.top-actions {
  gap: 10px;
}

.icon-button,
.export-button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  font-size: 20px;
}

.export-button {
  padding: 0 14px;
  background: #17202f;
  color: #ffffff;
}

.toolbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segment {
  min-width: 76px;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

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

.compact .segment {
  min-width: 68px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.metric-card {
  padding: 18px;
}

.metric-card span,
.metric-card small,
.panel-header p {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 28px;
  line-height: 1;
}

.metric-card small {
  color: var(--green);
}

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

.metric-card.highlight {
  border-color: rgba(8, 145, 178, 0.3);
  background: #f0fbfc;
}

.project-section {
  margin: 22px 0 16px;
}

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

.section-title h2 {
  font-size: 24px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f7ef;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.project-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.project-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.project-meta {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.project-meta span,
.dimension-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.project-meta strong {
  display: block;
  line-height: 1.45;
}

.dimension-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.dimension-list {
  display: grid;
  gap: 10px;
}

.dimension-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.dimension-card strong {
  display: block;
  margin-bottom: 10px;
}

.dimension-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dimension-stats b {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.dimension-stats small {
  color: var(--muted);
}

.audience-compare-panel,
.heatmap-panel,
.bid-panel {
  margin-bottom: 16px;
}

.audience-compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}

.audience-heatmap {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.audience-heatmap-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.audience-heatmap-title strong {
  font-weight: 700;
}

.audience-heatmap-title span {
  color: var(--muted);
  font-size: 12px;
}

.mini-heatmap {
  display: grid;
  grid-template-columns: minmax(78px, 1.05fr) repeat(3, minmax(58px, 1fr));
  gap: 6px;
}

.heatmap-axis,
.heatmap-creative {
  min-height: 34px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.heatmap-creative {
  color: var(--ink);
}

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

.heatmap-cell {
  min-height: 82px;
  padding: 8px;
  border: 1px solid rgba(23, 32, 47, 0.08);
  border-radius: 8px;
}

.heatmap-cell strong {
  margin-bottom: 5px;
  font-size: 13px;
}

.heatmap-cell span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.heatmap-cell small {
  margin-top: 4px;
  color: rgba(23, 32, 47, 0.72);
  font-size: 11px;
}

.bid-strategy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.bid-strategy-grid .dimension-card {
  background: #fbfcfe;
}

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

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

.trend-panel,
.table-panel {
  grid-column: span 1;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-header p {
  margin-top: 4px;
  font-size: 13px;
}

select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

canvas {
  width: 100%;
  height: 320px;
}

.breakdown-list,
.insight-list {
  display: grid;
  gap: 12px;
}

.breakdown-item {
  display: grid;
  gap: 8px;
}

.breakdown-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

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

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

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

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

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.insight {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.insight p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 1080px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  .app-shell {
    margin-left: 0;
  }

  .metric-grid,
  .project-grid,
  .dimension-grid,
  .audience-compare-grid,
  .heatmap,
  .bid-strategy-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding: 18px;
  }

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

  .segmented {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-grid,
  .project-grid,
  .dimension-grid,
  .audience-compare-grid,
  .heatmap,
  .bid-strategy-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

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