:root {
  --bg: #f5f6fa;
  --fg: #1f2937;
  --subtle: #6b7280;
  --primary: #4c6ef5;
  --primary-strong: #3b5bdb;
  --positive: #27ae60;
  --neutral: #f39c12;
  --negative: #e74c3c;
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 20px 45px -20px rgba(15, 23, 42, 0.35);
  --radius: 16px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.page {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  width: 100%;
  max-width: calc(1200px + 340px + 28px + 48px);
  margin: 0 auto;
  padding: 0 24px 96px;
}

.page > .container {
  flex: 1 1 auto;
}

#appLayout {
  margin-top: 32px;
}

.filters {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  position: sticky;
  top: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  margin-top: 48px;
  width: 340px;
  flex: 0 0 340px;
}

.filters__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filters__header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.filters__body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
  flex: 1 1 auto;
}

.filters__reset {
  border: none;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--subtle);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.filters__reset:hover {
  background: rgba(76, 110, 245, 0.12);
  color: var(--primary);
}

.filters__group {
  display: flex;
  flex-direction: column;
}

.filters__group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filters__group-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtle);
  font-weight: 600;
  flex: 1;
}

.filters__group-toggle {
  border: none;
  background: transparent;
  color: var(--subtle);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.filters__group-toggle:hover,
.filters__group-toggle:focus-visible {
  background: rgba(76, 110, 245, 0.12);
  color: var(--primary);
  outline: none;
}

.filters__chevron {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  margin-top: -2px;
}

.filters__group:not(.filters__group--collapsed) .filters__chevron {
  transform: rotate(45deg);
}

.filters__group-content {
  margin-top: 12px;
}

.filters__group--collapsed .filters__group-content {
  display: none;
}

.filters__logic {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.filters__group--collapsed .filters__logic {
  display: none;
}

.filters__logic-btn {
  border: none;
  background: rgba(76, 110, 245, 0.12);
  color: var(--primary);
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.filters__logic-btn:hover,
.filters__logic-btn:focus-visible {
  background: rgba(76, 110, 245, 0.22);
  outline: none;
  transform: translateY(-1px);
}

.filters__logic-btn--active {
  background: var(--primary);
  color: #fff;
}


.filters__select {
  border: 1px solid rgba(79, 114, 255, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5ff 100%);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.filters__select:focus {
  outline: none;
  border-color: rgba(79, 114, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.18);
}

.filters__input {
  border: 1px solid rgba(79, 114, 255, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f5f7ff 100%);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.filters__input::placeholder {
  color: rgba(15, 23, 42, 0.45);
}

.filters__input:focus {
  outline: none;
  border-color: rgba(79, 114, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.18);
}

.filters__select--country{
  padding-right: 44px;
  border-color: rgba(79, 114, 255, 0.35);
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(135deg, #ffffff 0%, #eef2ff 100%),
    url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.41.59 6 5.17 10.59.59 12 2l-6 6-6-6L1.41.59Z' fill='%234c6ef5'/%3E%3C/svg%3E");
  background-position: left top, right 14px center;
  background-repeat: no-repeat;
  background-size: 100% 100%, 12px 8px;
  box-shadow: 0 6px 16px rgba(76, 110, 245, 0.12);
}

.filters__select--country:hover{
  border-color: rgba(79, 114, 255, 0.55);
  box-shadow: 0 10px 22px rgba(76, 110, 245, 0.18);
}

.filters__select--country:focus{
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.22);
}

.filters__dates {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.filters__date-input {
  border: 1px solid rgba(79, 114, 255, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--fg);
}

.filters__date-input:focus {
  outline: none;
  border-color: rgba(79, 114, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.18);
}


.header {
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}

.header h1 {
  font-size: clamp(2.4rem, 5vw, 3rem);
  margin: 0;
  letter-spacing: -0.02em;
}

.external-link {
  margin: 24px 0 32px;
  text-align: center;
}

.external-link a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.external-link a:hover {
  color: var(--primary-strong);
}

.info {
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}

.info--loading {
  color: var(--subtle);
}

.info--error {
  color: var(--negative);
}

.comments-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.comments-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(135deg, rgba(76, 110, 245, 0.08), transparent 55%);
}

.comments-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.comments-count {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--subtle);
}

.comments-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.comments-load-more {
  margin: 16px auto 24px;
  padding: 12px 24px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.comments-load-more:hover,
.comments-load-more:focus-visible {
  background: var(--primary-strong);
  transform: translateY(-1px);
  outline: none;
}

.comment {
  display: flex;
  gap: 24px;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  transition: background-color 0.2s ease;
}

.comment:last-child {
  border-bottom: none;
}

.comment:hover {
  background: rgba(79, 114, 255, 0.035);
}

.comment-left {
  flex: 0 0 180px;
  background: #f3f4f6;
  border-radius: 14px;
  border: 1px solid rgba(79, 114, 255, 0.18);
  padding: 20px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.sentiment-face {
  font-size: 2.2rem;
}

.sentiment-label {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
}

.sentiment-score {
  font-size: 1.6rem;
  font-weight: 700;
}

.comment-date {
  font-size: 0.9rem;
  color: var(--subtle);
}

.comment-right {
  flex: 1;
  display: grid;
  gap: 18px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.comment-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.comment-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  flex: 1;
}

.comment-meta {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--subtle);
}

.comment-user-type {
  font-size: 0.9rem;
  color: var(--subtle);
  align-self: flex-start;
  text-align: right;
  margin-left: auto;
}

.comment-header > div:first-child {
  flex: 1 1 auto;
}

.comment-user-type:empty {
  display: none;
}

.comment-summary {
  padding: 18px 20px;
  background: rgba(15, 23, 42, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--fg);
  font-weight: 500;
}

.comment-tags {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.tag-group h4,
.comment-arguments h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--subtle);
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.1);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--subtle);
}

.tag-pills .pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--subtle);
}

.comment-arguments {
  background: rgba(15, 23, 42, 0.035);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.07);
  padding: 16px 18px;
}

.arguments-list {
  margin: 0;
  padding-left: 18px;
  color: var(--fg);
  display: grid;
  gap: 10px;
}

.arguments-list li {
  line-height: 1.5;
}

.comment-actions {
  display: flex;
  justify-content: flex-start;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(79, 114, 255, 0.35);
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(79, 114, 255, 0.12), rgba(79, 114, 255, 0.05));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.btn-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -12px rgba(79, 114, 255, 0.45);
  border-color: rgba(79, 114, 255, 0.6);
}

.btn-link:focus-visible {
  outline: 2px solid rgba(79, 114, 255, 0.6);
  outline-offset: 2px;
}

.comment-left.sentiment-positive {
  background: linear-gradient(135deg, rgba(39, 174, 96, 0.12), rgba(39, 174, 96, 0.05));
  border-color: rgba(39, 174, 96, 0.25);
}

.comment-left.sentiment-positive .sentiment-score {
  color: var(--positive);
}

.comment-left.sentiment-neutral {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.12), rgba(243, 156, 18, 0.05));
  border-color: rgba(243, 156, 18, 0.25);
}

.comment-left.sentiment-neutral .sentiment-score {
  color: var(--neutral);
}

.comment-left.sentiment-negative {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.12), rgba(231, 76, 60, 0.05));
  border-color: rgba(231, 76, 60, 0.25);
}

.comment-left.sentiment-negative .sentiment-score {
  color: var(--negative);
}

@media (max-width: 900px) {
  .header {
    padding: 28px 24px;
  }

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

  .filters {
    position: static;
    max-height: none;
  }

  .comment {
    flex-direction: column;
  }

  .comment-left {
    flex-direction: row;
    gap: 16px;
    justify-content: space-between;
  }

  .comment-right {
    gap: 16px;
  }

  .comments-section {
    max-height: none;
  }

  .comments-list {
    max-height: none;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 32px 16px 80px;
  }

  .comments-header {
    padding: 20px;
  }

  .comment {
    padding: 20px;
  }
}
.filters__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters__pill {
  padding: 8px 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--fg);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.filters__pill:hover {
  background: rgba(76, 110, 245, 0.12);
  border-color: rgba(79, 114, 255, 0.4);
}

.filters__pill--active {
  background: linear-gradient(135deg, rgba(76, 110, 245, 0.9), rgba(110, 82, 255, 0.9));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 20px -12px rgba(76, 110, 245, 0.45);
}

:root{
  --card-bg:#fff;
  --border:#e5e7eb;
  --text:#111827;
  --muted:#6b7280;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 20px rgba(0,0,0,.06);

  --c-favor:#27ae60;
  --c-neutral:#f39c12;
  --c-opposed:#e74c3c;
}

/* Grid container */
#kpiGrid{
  display: grid;
  gap: 16px;
}

/* Each row is a grid */
.kpi-row{ display:grid; gap:16px; }

/* Row 1: 5 compact tiles */
.kpi-row--counts{ grid-template-columns: repeat(5, minmax(0,1fr)); }
.kpi-row--counts .kpi-tile{ min-height: 96px; }

/* Row 2: 2 larger tiles */
.kpi-row--big{ grid-template-columns: repeat(2, minmax(0,1fr)); }
.kpi-row--big .kpi-tile{ min-height: 280px; }

.kpi-row--wide{ grid-template-columns: minmax(0,1fr); }
.kpi-row--wide .kpi-tile{ min-height: 280px; }

/* Row 3: 3 pies */
.kpi-row--pies{ grid-template-columns: repeat(3, minmax(0,1fr)); }
.kpi-row--pies .kpi-tile{ min-height: 240px; }

/* Tile look */
.kpi-tile{
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Titles & values */
.kpi-title{
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value{
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.kpi-subvalue{
  font-size: .9rem;
  color: var(--muted);
}

/* Color accents for stance */
#kpiFavorCount, #kpiFavorPct{ color: var(--c-favor); }
#kpiNeutralCount, #kpiNeutralPct{ color: var(--c-neutral); }
#kpiOpposedCount, #kpiOpposedPct{ color: var(--c-opposed); }

/* Last updated look */
#kpiLastUpdated{
  font-size: 1rem;
  color: var(--text);
  margin-top: 6px;
  margin-bottom: 6px;
}

/* Make canvases fill their card area */
.kpi-tile canvas{
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Optional: subtle empty-state message for charts */
.chart-empty-msg{
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
  padding: .5rem;
}

/* Responsive tweaks */
@media (max-width: 1200px){
  .kpi-row--counts{ grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kpi-row--pies{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px){
  .kpi-row--counts{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi-row--big{ grid-template-columns: 1fr; }
}
@media (max-width: 560px){
  .kpi-row--counts{ grid-template-columns: 1fr; }
  .kpi-row--pies{ grid-template-columns: 1fr; }
  .kpi-value{ font-size: 1.5rem; }
}

/* 2) Titles bold, values not bold */
.kpi-title{ font-weight: 700; }    /* bold titles */
.kpi-value{ font-weight: 400; }    /* normal (not bold) values */

/* 3) First row: center all text/content */
.kpi-row--counts .kpi-tile{
  text-align: center;
  align-items: center;     /* centers flex children horizontally */
  justify-content: center; /* keep content vertically tidy */
}

/* Ensure all bits in row 1 are centered */
.kpi-row--counts .kpi-title,
.kpi-row--counts .kpi-value,
.kpi-row--counts .kpi-subvalue{
  margin-left: auto;
  margin-right: auto;
}

/* Optional: slightly tighter first row cards */
.kpi-row--counts .kpi-tile{ min-height: 88px; }
.kpi-row--counts .kpi-subvalue{ margin-top: -2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
