:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-strong: #f0f4f5;
  --ink: #1b2224;
  --muted: #607074;
  --soft: #8b989b;
  --line: #dfe6e8;
  --line-strong: #c7d2d6;
  --teal: #087f7a;
  --teal-dark: #065f5b;
  --teal-soft: #d9f0ee;
  --amber: #b87504;
  --amber-soft: #fff2cf;
  --lavender: #6d6bb3;
  --lavender-soft: #e8e8fb;
  --red: #b53f45;
  --red-soft: #fde5e7;
  --shadow: 0 12px 30px rgba(24, 36, 40, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border-radius: var(--radius-sm);
}

button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
}

button:hover,
button:focus-visible,
a.source-link:hover,
a.source-link:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.app-shell {
  max-width: 1740px;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  font-weight: 760;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.4;
  max-width: 780px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-link,
#resetFilters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.metric-tile {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 15px 16px;
}

.metric-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--line-strong);
}

.metric-tile.accent-teal::before {
  background: var(--teal);
}

.metric-tile.accent-amber::before {
  background: var(--amber);
}

.metric-tile.accent-lavender::before {
  background: var(--lavender);
}

.metric-tile span,
.panel-head span,
.filter-summary,
.meta,
.mini-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-tile strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1;
}

.metric-tile small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.insight-card {
  padding: 12px;
  min-height: 118px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.insight-card:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}

.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 760;
  text-transform: uppercase;
}

.insight-card strong {
  display: block;
  margin-top: 7px;
  font-size: 14px;
  line-height: 1.22;
}

.insight-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.filters {
  position: sticky;
  top: 16px;
  padding: 14px;
}

.filter-block {
  margin-bottom: 14px;
}

.filter-block label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 730;
}

.filter-block input[type="search"],
.filter-block select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 9px;
}

.filter-block input[type="search"]:focus,
.filter-block select:focus {
  border-color: var(--teal);
  outline: 2px solid var(--teal-soft);
}

.checkbox-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
}

.checkbox-row label {
  margin: 0;
}

.filter-summary {
  padding: 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  line-height: 1.45;
}

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

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
}

.tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 3px 0 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.85fr);
  gap: 12px;
}

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

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

.panel-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.bar-list,
.band-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(110px, 44%) auto;
  gap: 10px;
  align-items: center;
  min-height: 28px;
}

.bar-list.compact .bar-row {
  grid-template-columns: minmax(120px, 1fr) minmax(90px, 38%) auto;
}

.bar-label {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 660;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  background: var(--surface-strong);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--teal);
}

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

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

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

.band-row {
  display: grid;
  grid-template-columns: 92px 1fr 56px;
  gap: 10px;
  align-items: center;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 11px;
  text-align: right;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f5f7f8;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 1;
}

td:first-child,
th:first-child {
  text-align: left;
  min-width: 260px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef8f7;
}

.video-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.episode-mark {
  width: 46px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
  border: 1px solid #b9dedb;
}

.video-title {
  display: block;
  max-width: 360px;
  color: var(--ink);
  font-weight: 740;
  line-height: 1.25;
}

.video-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.score-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.score-pill.amber {
  background: var(--amber-soft);
  color: #755000;
}

.score-pill.lavender,
.tag.lavender {
  background: var(--lavender-soft);
  color: #45438c;
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

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

.comment-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  cursor: pointer;
}

.comment-row:hover,
.comment-row.selected {
  border-color: var(--teal);
}

.comment-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.comment-row strong {
  font-size: 13px;
}

.comment-row p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.comment-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.detail-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.detail-card {
  padding: 14px;
}

.detail-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.25;
}

.detail-card p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.detail-card a {
  color: var(--teal-dark);
  font-weight: 720;
}

.detail-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin: 0 0 10px;
  background: var(--surface-strong);
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.mini-metric {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfc;
}

.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 760;
}

.mini-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.detail-comment {
  white-space: pre-wrap;
  color: var(--ink) !important;
  font-size: 13px;
  line-height: 1.5;
  max-height: 420px;
  overflow: auto;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfc;
}

.highlight-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.highlight-comment {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px;
  background: #fbfcfc;
  cursor: pointer;
}

.highlight-comment:hover {
  border-color: var(--teal);
}

.highlight-comment span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.highlight-comment p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  color: var(--ink);
}

.empty-state {
  border: 1px dashed var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1320px) {
  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-strip {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

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

  .topbar,
  .section-heading {
    display: block;
  }

  .topbar-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

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

  .workspace,
  .overview-grid,
  .detail-panel {
    grid-template-columns: 1fr;
  }

  .filters,
  .detail-panel {
    position: static;
  }

  .insight-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 22px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    white-space: nowrap;
  }

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

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