:root {
  color-scheme: light;
  --ink: #18202d;
  --muted: #657184;
  --line: #dce3eb;
  --page: #f4f7f9;
  --surface: #ffffff;
  --teal: #087f8c;
  --green: #2f8f5b;
  --coral: #d75d3f;
  --gold: #b68416;
  --blue: #315f96;
  --navy: #172232;
  --soft-teal: #e8f5f6;
  --soft-green: #eaf6ef;
  --soft-coral: #fbede8;
  --soft-gold: #fbf5e5;
  --shadow: 0 18px 45px rgba(25, 39, 60, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell > *,
main > * {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: var(--navy);
  color: #f8fbfd;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 900;
}

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

.brand span {
  color: #9baaba;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  color: #c5d0dc;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 7px;
}

.nav-list a:hover,
.nav-list a.active {
  background: #25354b;
  color: #fff;
}

.sidebar-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.panel-label,
.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-panel .panel-label {
  color: #9baaba;
}

.sidebar-panel strong {
  display: block;
  font-size: 28px;
}

.sidebar-panel p {
  margin: 8px 0 0;
  color: #becbd9;
  font-size: 13px;
  line-height: 1.45;
}

main {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.topbar,
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.topbar h1,
.section-heading h2 {
  margin: 0;
}

.topbar h1 {
  max-width: 860px;
  font-size: clamp(30px, 4.5vw, 48px);
  line-height: 1.04;
}

.sync-card {
  min-width: 210px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sync-card span,
.sync-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.sync-card strong {
  display: block;
  margin: 4px 0;
  font-size: 18px;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) repeat(2, minmax(140px, 0.8fr)) minmax(240px, 1.4fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.15);
}

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

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

.metric-card {
  padding: 18px;
  min-height: 132px;
}

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

.metric-card span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.metric-positive {
  color: var(--green);
  font-weight: 800;
}

.metric-warning {
  color: var(--gold);
  font-weight: 800;
}

.panel {
  padding: 20px;
}

.dashboard-grid,
.advisory-layout,
.analysis-layout,
.management-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 22px;
}

.trend-panel {
  min-height: 382px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-width: 92px;
  border: 0;
  background: #fff;
  padding: 9px 12px;
}

.segmented button.active {
  background: var(--navy);
  color: #fff;
}

#trendChart {
  width: 100%;
  margin-top: 18px;
}

.signal-list,
.advisory-list,
.comment-pulse,
.action-list,
.playbook-list {
  display: grid;
  gap: 10px;
}

.signal-item,
.advisory-item,
.comment-item,
.action-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.signal-item strong,
.advisory-item strong,
.comment-item strong,
.action-item strong {
  display: block;
  margin-bottom: 5px;
}

.signal-item span,
.advisory-item span,
.comment-item span,
.action-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.account-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfd;
}

.account-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.account-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-avatar {
  position: relative;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--soft-teal);
  color: var(--teal);
  font-weight: 900;
}

.account-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-top h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.account-top span,
.account-card small {
  color: var(--muted);
}

.account-bio {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.account-stats div {
  padding: 10px;
  border-radius: 7px;
  background: #fff;
}

.account-stats strong {
  display: block;
  font-size: 18px;
}

.account-stats span {
  color: var(--muted);
  font-size: 12px;
}

.soft-badge,
.state-badge,
.risk-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.soft-badge {
  background: var(--soft-teal);
  color: var(--teal);
}

.risk-ok,
.state-winner {
  background: var(--soft-green);
  color: var(--green);
}

.risk-watch,
.state-needs-more-time,
.state-reach-only {
  background: var(--soft-gold);
  color: var(--gold);
}

.risk-risk,
.state-weak-test {
  background: var(--soft-coral);
  color: var(--coral);
}

.state-community-signal {
  background: #eaf0fa;
  color: var(--blue);
}

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

.leaderboard-guide {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.guide-intro {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}

.guide-intro span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.score-formula {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.score-formula span {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--soft-teal);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.score-formula strong {
  color: var(--teal);
}

.classification-guide {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.classification-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.classification-card .state-badge {
  justify-self: start;
}

.classification-card strong {
  font-size: 13px;
  line-height: 1.4;
}

.classification-card > span:not(.state-badge),
.classification-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td strong {
  display: block;
  margin-bottom: 4px;
}

td small {
  color: var(--muted);
}

.secondary-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

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

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

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

.report-card.wide {
  grid-column: span 2;
}

.report-card strong,
.report-card span {
  display: block;
}

.report-card span,
.report-card li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.report-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.analyzer-form,
.analyzer-form label {
  display: grid;
  gap: 10px;
}

.analyzer-form {
  gap: 16px;
}

.form-row,
.slider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

input[type="range"] {
  accent-color: var(--teal);
  padding: 0;
}

.result-panel {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.score-ring {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background: conic-gradient(var(--teal) 84%, #e4eaf1 0);
  box-shadow: inset 0 0 0 16px #fff;
}

.score-ring span {
  display: block;
  color: var(--ink);
  font-size: 44px;
  font-weight: 900;
}

.score-ring small {
  color: var(--muted);
  font-weight: 800;
}

.playbook-list {
  margin-top: 16px;
}

.playbook-list div {
  padding: 12px;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #fbf8ef;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.settings-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.settings-grid h3 {
  margin: 0 0 8px;
}

.settings-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #edf2f6;
}

.inline-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(880px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(23, 34, 50, 0.28);
}

dialog::backdrop {
  background: rgba(23, 34, 50, 0.48);
}

.dialog-card {
  display: grid;
  gap: 16px;
  padding: 22px;
  background: var(--surface);
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.detail-metrics div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
}

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

.detail-metrics span {
  color: var(--muted);
  font-size: 12px;
}

tr[data-video-id] {
  cursor: pointer;
}

tr[data-video-id]:hover,
.account-card[data-account-id]:hover {
  background: #f8fafc;
}

.account-card[data-account-id] {
  cursor: pointer;
}

@media (max-width: 1120px) {
  .metrics-grid,
  .account-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-bar,
  .dashboard-grid,
  .advisory-layout,
  .analysis-layout,
  .management-layout,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  .trend-panel,
  #videos,
  #actions,
  #settings {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  main {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .result-panel {
    align-items: stretch;
    display: grid;
  }

  .control-bar,
  .metrics-grid,
  .dashboard-grid,
  .advisory-layout,
  .analysis-layout,
  .management-layout,
  .account-grid,
  .form-row,
  .slider-grid,
  .settings-grid,
  .detail-metrics,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .report-card.wide {
    grid-column: auto;
  }

  .segmented {
    width: 100%;
    grid-auto-columns: 1fr;
  }

  .segmented button {
    min-width: 0;
  }
}
