:root {
  --bg: #f5f7f3;
  --panel: #ffffff;
  --panel-2: #f9faf8;
  --ink: #20251f;
  --muted: #687064;
  --line: #dfe5dc;
  --blue: #2563a7;
  --green: #2f7d5c;
  --amber: #b56b1d;
  --red: #b23b4b;
  --violet: #6b5796;
  --shadow: 0 10px 30px rgba(33, 38, 30, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.88);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.3;
}

.tabs,
.pills,
.score-row,
.moment-head,
.selected-bar {
  display: flex;
  align-items: center;
}

.shell {
  display: grid;
  grid-template-columns: minmax(340px, 42vw) 1fr;
  gap: 18px;
  padding: 18px;
}

.watch-pane {
  position: sticky;
  top: 91px;
  align-self: start;
  display: grid;
  gap: 12px;
}

.video-wrap {
  background: #10140f;
  border: 1px solid #121712;
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
}

.video-wrap video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  object-fit: contain;
}

.selected-bar,
.workbench,
.detail-pane,
.list-pane,
.chart-panel,
.timeline-table,
.markdown-pane,
.producer-lists {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.selected-bar {
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.meta-line {
  margin: 0;
  color: var(--muted);
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status-line.error {
  color: var(--red);
  font-weight: 700;
}

.workbench {
  min-width: 0;
  overflow: hidden;
}

.tabs {
  gap: 2px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 11px;
  cursor: pointer;
}

.tab.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.tab-panel {
  display: none;
  padding: 14px;
}

.tab-panel.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px 150px;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 5px 9px;
  cursor: pointer;
}

.filter-chip.active {
  border-color: rgba(37, 99, 167, 0.32);
  background: rgba(37, 99, 167, 0.08);
  color: var(--blue);
  font-weight: 700;
}

.filter-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.filter-chip.active span {
  color: var(--blue);
}

.thresholds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}

.thresholds label {
  display: grid;
  gap: 4px;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

input[type="range"] {
  padding: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(260px, 39%) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.executive-view {
  display: grid;
  gap: 14px;
}

.executive-hero {
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.executive-hero h2 {
  font-size: 20px;
}

.executive-hero p:last-child {
  margin-bottom: 0;
}

.executive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

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

.executive-section {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.executive-card-list {
  display: grid;
  gap: 8px;
}

.executive-card {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  text-align: left;
  padding: 11px;
  cursor: pointer;
}

.executive-card:hover {
  background: #f1f6f0;
}

.executive-card span,
.executive-card p {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.executive-card strong {
  display: block;
  margin: 4px 0;
  line-height: 1.3;
}

.executive-card p {
  margin-bottom: 0;
  line-height: 1.35;
}

.list-pane {
  max-height: calc(100vh - 250px);
  overflow: auto;
}

.list-summary {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.moment-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  padding: 12px;
  cursor: pointer;
}

.moment-item:hover,
.moment-item.active {
  background: #f1f6f0;
}

.moment-head {
  justify-content: space-between;
  gap: 10px;
}

.moment-title {
  margin: 0;
  font-weight: 750;
  line-height: 1.28;
}

.moment-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.pills {
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill.blue {
  color: var(--blue);
  border-color: rgba(37, 99, 167, 0.28);
  background: rgba(37, 99, 167, 0.08);
}

.pill.blue.active-use {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.pill.green {
  color: var(--green);
  border-color: rgba(47, 125, 92, 0.3);
  background: rgba(47, 125, 92, 0.08);
}

.pill.amber {
  color: var(--amber);
  border-color: rgba(181, 107, 29, 0.3);
  background: rgba(181, 107, 29, 0.08);
}

.pill.red {
  color: var(--red);
  border-color: rgba(178, 59, 75, 0.3);
  background: rgba(178, 59, 75, 0.08);
}

.detail-pane {
  min-height: 480px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding: 16px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 14px 0;
}

.score-row {
  gap: 8px;
}

.score-name {
  flex: 0 0 128px;
  color: var(--muted);
  font-size: 12px;
}

.score-track {
  height: 8px;
  flex: 1 1 auto;
  background: #e7ece3;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--green);
}

.score-value {
  width: 32px;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
}

.evidence-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.evidence-section ul {
  margin: 0;
  padding-left: 18px;
}

.evidence-section li {
  margin-bottom: 6px;
  color: #343a33;
}

.primary-button,
.secondary-button,
.icon-link {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

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

.secondary-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--blue);
  border-color: rgba(37, 99, 167, 0.3);
  background: rgba(37, 99, 167, 0.06);
}

.icon-link.disabled {
  pointer-events: none;
  opacity: 0.35;
}

.chart-panel {
  padding: 10px;
  margin-bottom: 12px;
}

#timelineChart {
  display: block;
  width: 100%;
  height: auto;
  background: #fbfcfa;
}

#timelineChart text {
  user-select: none;
}

#timelineChart .moment-dot,
#timelineChart .timeline-bin-hit {
  cursor: pointer;
}

.timeline-table {
  max-height: calc(100vh - 380px);
  overflow: auto;
}

.timeline-list-head {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 128px;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.timeline-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 128px;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.timeline-row:hover {
  background: #f1f6f0;
}

.timeline-time {
  display: grid;
  align-content: start;
  gap: 3px;
}

.timeline-time strong {
  font-size: 20px;
  line-height: 1;
}

.timeline-time span,
.timeline-support-text,
.timeline-evidence-text,
.timeline-warning-text {
  color: var(--muted);
  font-size: 12px;
}

.timeline-context-cell {
  min-width: 0;
}

.timeline-topline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 6px;
  font-weight: 720;
}

.timeline-quarter,
.timeline-score-range {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(37, 99, 167, 0.24);
  background: rgba(37, 99, 167, 0.07);
  color: var(--blue);
  font-size: 12px;
  white-space: nowrap;
}

.timeline-score-range {
  border-color: rgba(47, 125, 92, 0.28);
  background: rgba(47, 125, 92, 0.08);
  color: var(--green);
}

.timeline-context-text {
  margin: 0 0 5px;
  font-weight: 650;
  line-height: 1.35;
}

.timeline-support-text,
.timeline-evidence-text,
.timeline-warning-text {
  margin: 4px 0 0;
  line-height: 1.35;
}

.timeline-warning-text {
  color: var(--amber);
}

.timeline-chip-row,
.timeline-moment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.timeline-chip,
.timeline-moment-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.timeline-chip.state {
  border-color: rgba(181, 107, 29, 0.26);
  background: rgba(181, 107, 29, 0.07);
  color: var(--amber);
}

.timeline-chip.entity {
  border-color: rgba(107, 87, 150, 0.24);
  background: rgba(107, 87, 150, 0.08);
  color: var(--violet);
}

.timeline-moment-chip {
  border-color: rgba(178, 59, 75, 0.26);
  background: #fff;
  color: var(--red);
  cursor: pointer;
}

.timeline-moment-chip:hover {
  background: rgba(178, 59, 75, 0.08);
}

.timeline-signal-cell {
  display: grid;
  align-content: start;
  gap: 10px;
}

.mini-score {
  display: grid;
  grid-template-columns: 18px 34px;
  grid-template-rows: auto 7px;
  gap: 3px 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mini-score strong {
  color: var(--ink);
  text-align: right;
}

.mini-score i {
  grid-column: 1 / -1;
  display: block;
  height: 7px;
  background: var(--green);
  max-width: 100%;
}

.mini-score.red i {
  background: var(--red);
}

.producer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
}

.markdown-pane,
.producer-lists {
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 16px;
}

.markdown-pane h1 {
  font-size: 22px;
  margin-bottom: 14px;
}

.markdown-pane h2 {
  margin-top: 18px;
}

.markdown-pane li {
  margin-bottom: 7px;
}

.producer-card {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.producer-card:first-child {
  padding-top: 0;
}

.producer-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

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

  .watch-pane {
    position: static;
  }

  .detail-pane,
  .list-pane,
  .markdown-pane,
  .producer-lists,
  .timeline-table {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar,
  .shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .filters,
  .thresholds,
  .content-grid,
  .executive-grid,
  .producer-layout {
    grid-template-columns: 1fr;
  }

  .timeline-row {
    grid-template-columns: 74px 74px 1fr;
  }

  .timeline-row span:nth-last-child(-n + 2) {
    display: none;
  }
}
