:root {
  color-scheme: light;
  --bg: #fbfcfc;
  --ink: #101010;
  --muted: #74746c;
  --soft: #989890;
  --line: #e7e7e1;
  --panel: #ffffff;
  --panel-2: #f8f8f5;
  --teal: #10a37f;
  --amber: #c27b21;
  --rose: #d65f75;
  --indigo: #5d6ad2;
  --slate: #5d646b;
  --green: #128a5c;
  --red: #be4141;
  --shadow: 0 18px 48px rgba(16, 16, 16, 0.055);
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.9) 34%, #ffffff 78%),
    url("data/codex-canva-gradient.png") top center / 100% auto no-repeat,
    radial-gradient(circle at 12% 10%, rgba(16, 163, 127, 0.08), transparent 26rem),
    radial-gradient(circle at 76% 0%, rgba(93, 106, 210, 0.08), transparent 30rem),
    var(--bg);
  background-attachment: scroll, fixed, fixed, fixed, scroll;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "kern";
  text-rendering: geometricPrecision;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 20px 48px 18px;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(227, 227, 220, 0.86);
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  object-position: center center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16, 16, 16, 0.06);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 760;
  max-width: 680px;
}

h2 {
  font-size: 15px;
  line-height: 1.22;
  letter-spacing: 0;
  font-weight: 720;
}

.eyebrow,
.section-kicker,
.source-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0;
  text-transform: uppercase;
}

.data-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.data-menu-button {
  min-width: 136px;
}

.data-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 60;
  width: min(380px, calc(100vw - 32px));
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(16, 16, 16, 0.14);
  backdrop-filter: blur(18px);
}

.source-panel {
  display: grid;
  gap: 4px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--line);
}

.source-panel strong,
.source-panel small {
  display: block;
}

.source-panel strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 740;
}

.source-panel small {
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.25;
}

.data-menu-actions {
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.icon-button,
.text-button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  place-items: center;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
}

.text-button {
  min-width: 112px;
  padding: 0 15px;
}

.icon-button:hover,
.primary-action:hover,
.secondary-action:hover,
.segment:hover {
  transform: translateY(-1px);
}

.menu-action {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 11px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 680;
  text-align: left;
}

.menu-action:hover {
  background: #f7f7f4;
}

.menu-action input {
  display: none;
}

main {
  padding: 24px 48px 56px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 236px minmax(180px, 240px) minmax(180px, 240px);
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.search-box,
.select-box {
  display: grid;
  gap: 6px;
}

.search-box span,
.select-box span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 650;
}

.search-box input,
.select-box select,
.panel-head select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 0 13px;
  font-size: 14px;
}

.segmented {
  display: inline-flex;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
}

.segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  flex: 1;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 680;
}

.segment.is-active {
  background: var(--ink);
  color: #fff;
}

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

.kpi,
.panel,
.table-section,
.insight-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.priority-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.4fr);
  gap: 14px;
  margin-bottom: 14px;
}

.health-panel,
.boost-panel {
  min-height: 280px;
}

.health-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 40px;
  border-radius: 999px;
  background: #edf0eb;
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  letter-spacing: 0;
}

.health-score.strong {
  background: #ddf2e8;
  color: #126843;
}

.health-score.healthy {
  background: #e8f0ff;
  color: #3546aa;
}

.health-score.watch {
  background: #fff1d8;
  color: #80510d;
}

.health-score.risk {
  background: #f7dddd;
  color: #8f3028;
}

.health-summary {
  color: #2f3633;
  font-size: 13px;
  line-height: 1.55;
  margin: -4px 0 16px;
}

.health-breakdown {
  display: grid;
  gap: 12px;
}

.health-row {
  display: grid;
  grid-template-columns: minmax(142px, 1fr) minmax(96px, 0.8fr) 44px;
  gap: 12px;
  align-items: center;
}

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

.health-row strong {
  font-size: 13px;
  line-height: 1.2;
}

.health-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  margin-top: 2px;
}

.health-track {
  height: 9px;
  background: #eeeeea;
  border-radius: 999px;
  overflow: hidden;
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--indigo));
}

.health-row b {
  font-size: 12px;
  text-align: right;
}

.compact-note {
  margin: 0;
}

.boost-candidates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.boost-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.boost-card h3 {
  margin: 3px 0 0;
  font-size: 15px;
  line-height: 1.2;
}

.boost-card > strong {
  align-self: start;
  min-width: 38px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  padding: 0 10px;
  text-align: center;
  cursor: help;
}

.boost-card p,
.boost-metrics,
.card-actions {
  grid-column: 1 / -1;
}

.boost-card p {
  margin: 0;
  color: #2f3633;
  font-size: 13px;
  line-height: 1.42;
}

.boost-card .content-preview {
  color: var(--muted);
  font-size: 12px;
  margin-top: -3px;
}

.boost-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.boost-metrics span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 650;
}

.boost-card a {
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
  text-decoration: none;
}

.kpi {
  min-height: 118px;
  padding: 18px 18px 16px;
  border-top-width: 1px;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}

.kpi span,
.kpi small {
  display: block;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 680;
}

.kpi strong {
  display: block;
  margin-top: 7px;
  font-size: 30px;
  line-height: 1.04;
  letter-spacing: 0;
  font-weight: 760;
}

.kpi small {
  color: var(--muted);
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
}

.accent-teal {
  --accent: var(--teal);
}

.accent-amber {
  --accent: var(--amber);
}

.accent-rose {
  --accent: var(--rose);
}

.accent-indigo {
  --accent: var(--indigo);
}

.accent-slate {
  --accent: var(--slate);
}

.kpi.accent-teal::before,
.kpi.accent-amber::before,
.kpi.accent-rose::before,
.kpi.accent-indigo::before,
.kpi.accent-slate::before {
  background: var(--accent);
}

.insight-band {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: center;
  margin: 18px 0 20px;
  padding: 20px;
}

.insight-band p {
  max-width: 980px;
  color: #2f3633;
  font-size: 15px;
  line-height: 1.6;
  margin-top: 9px;
}

.primary-action,
.secondary-action {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.secondary-action {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr 0.9fr;
  gap: 14px;
}

.panel,
.table-section {
  padding: 18px;
}

.panel.wide {
  grid-column: span 2;
}

.sentiment-panel {
  grid-column: span 2;
}

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

.bar-chart {
  display: grid;
  gap: 11px;
}

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

.leader-row {
  display: grid;
  grid-template-columns: 42px minmax(220px, 1.1fr) minmax(210px, 0.9fr) minmax(180px, 0.8fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

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

.leader-main {
  min-width: 0;
}

.leader-actions,
.leader-subline,
.leader-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.leader-subline {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.leader-metrics {
  justify-content: flex-start;
}

.leader-metrics span {
  min-width: 62px;
  display: grid;
  gap: 2px;
}

.leader-metrics b {
  font-size: 15px;
  line-height: 1.05;
}

.leader-metrics small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.leader-bar {
  display: grid;
  grid-template-columns: 1fr 58px;
  gap: 10px;
  align-items: center;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(148px, 224px) 1fr minmax(72px, auto);
  gap: 14px;
  align-items: center;
}

.bar-label {
  min-width: 0;
}

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

.bar-label strong {
  font-size: 13px;
  line-height: 1.22;
  font-weight: 720;
}

.bar-label span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

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

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--indigo));
  border-radius: 999px;
}

.bar-value {
  text-align: right;
  font-size: 14px;
  font-weight: 740;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 144px 1fr;
  gap: 16px;
  align-items: center;
}

.donut {
  width: 144px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0 50%, var(--indigo) 50% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 31px;
  background: var(--panel);
  border-radius: 50%;
  border: 1px solid var(--line);
}

.legend {
  display: grid;
  gap: 10px;
}

.legend-item,
.sentiment-item,
.mix-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  line-height: 1.28;
}

.legend-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
}

.funnel {
  display: grid;
  gap: 11px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 118px 1fr 34px;
  gap: 11px;
  align-items: center;
  font-size: 13px;
}

.funnel-track,
.mix-track {
  height: 12px;
  background: #eeeeea;
  border-radius: 999px;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  background: var(--rose);
}

.stacked {
  display: grid;
  gap: 13px;
}

.mix-track {
  display: flex;
  overflow: hidden;
  height: 18px;
}

.mix-segment.likes {
  background: var(--teal);
}

.mix-segment.comments {
  background: var(--rose);
}

.mix-segment.saves {
  background: var(--amber);
}

.mix-segment.shares {
  background: var(--indigo);
}

.sentiment-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sentiment-card {
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.sentiment-card strong {
  display: block;
  font-size: 23px;
  line-height: 1.08;
  letter-spacing: 0;
  margin-top: 6px;
}

.sentiment-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0;
  text-transform: uppercase;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.table-section {
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.28;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f7f4;
  color: #3e3e39;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  font-weight: 720;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #f8faf6;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 720;
  background: #edf0eb;
  color: #3b4640;
}

.pill.live {
  background: #dff1e8;
  color: #166b49;
}

.pill.draft {
  background: #fff1d8;
  color: #80510d;
}

.pill.approved {
  background: #e8f0ff;
  color: #3546aa;
}

.pill.missing {
  background: #f7dddd;
  color: #8f3028;
}

.link-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.link-chip {
  min-width: 0;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  font-weight: 680;
  font-size: 12px;
  padding: 0 10px;
}

.link-chip.content-link {
  border-color: rgba(16, 163, 127, 0.28);
  background: rgba(16, 163, 127, 0.1);
  color: #0e6f58;
}

.link-chip.profile-link {
  border-color: rgba(93, 106, 210, 0.28);
  background: rgba(93, 106, 210, 0.1);
  color: #3546aa;
}

.link-chip.action-link {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.leaderboard-link {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 5px;
}

.leaderboard-link.secondary {
  font-size: 11px;
  font-weight: 650;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 50;
  width: min(470px, 100vw);
  transform: translateX(105%);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-left: 1px solid var(--line);
  padding: 24px;
  transition: transform 0.25s ease;
  overflow: auto;
}

.drawer.is-open {
  transform: translateX(0);
}

.close-button {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: grid;
}

.drawer h3 {
  margin: 8px 0 6px;
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.drawer-metric {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 13px;
}

.drawer-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0;
  text-transform: uppercase;
}

.drawer-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  line-height: 1.16;
  letter-spacing: 0;
}

.risk-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  transform: translate(-50%, 120px);
  min-width: 260px;
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .topbar,
  .insight-band {
    align-items: stretch;
    flex-direction: column;
  }

  .controls,
  .analytics-grid,
  .priority-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel.wide,
  .sentiment-panel {
    grid-column: span 2;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    padding: 18px 24px;
  }

  main {
    padding: 20px 24px 44px;
  }

  h1 {
    font-size: 25px;
    line-height: 1.12;
  }

  h2 {
    font-size: 14px;
  }

  .controls,
  .analytics-grid,
  .priority-grid,
  .kpi-grid,
  .sentiment-cards,
  .boost-candidates {
    grid-template-columns: 1fr;
  }

  .brand-heading {
    align-items: flex-start;
  }

  .brand-logo {
    width: 50px;
    height: 50px;
  }

  .data-menu-wrap,
  .data-menu-button {
    width: 100%;
  }

  .data-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  .panel.wide,
  .sentiment-panel {
    grid-column: auto;
  }

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

  .donut-wrap {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .leader-row {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .leader-bar {
    grid-template-columns: 1fr;
  }

  .bar-value {
    text-align: left;
  }

  .kpi {
    min-height: 104px;
  }

  .kpi strong {
    font-size: 28px;
  }

  .insight-band {
    padding: 18px;
  }

  .health-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .health-row b {
    text-align: left;
  }

  .readout-actions,
  .readout-actions button {
    width: 100%;
  }
}
