.trend-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f8fafc;
}

.trend-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.trend-filter {
  appearance: none;
  border: 1px solid #d6dee8;
  background: #ffffff;
  color: #526170;
  border-radius: 999px;
  padding: 8px 13px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.trend-filter:hover,
.trend-filter.active {
  background: #1f3a5f;
  border-color: #1f3a5f;
  color: #ffffff;
}

.trend-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 700;
}

.trend-badge .trend-arrow {
  font-size: 1.15rem;
  line-height: 1;
}

.trend-up {
  color: #166534;
  background: #dcfce7;
}

.trend-neutral {
  color: #4b5563;
  background: #e5e7eb;
}

.trend-down {
  color: #b91c1c;
  background: #fee2e2;
}

.trend-chart-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

#trendChart {
  display: block;
  width: 100%;
  min-width: 520px;
  height: auto;
}

.trend-point {
  cursor: pointer;
  outline: none;
}

/* SVG presentation colours follow the same opt-in theme as the surrounding card. */
@media screen {
  html[data-theme="dark"] #trendChart rect {
    fill: var(--theme-surface, #142235);
  }

  html[data-theme="dark"] #trendChart line {
    stroke: var(--theme-line, #34485f);
  }

  html[data-theme="dark"] #trendChart text {
    fill: var(--theme-muted, #b4c4d8);
  }

  html[data-theme="dark"] #trendChart .trend-point-dot {
    stroke: var(--theme-surface, #142235);
  }
}

.trend-point .trend-point-dot {
  transition: r 0.15s ease, stroke-width 0.15s ease, filter 0.15s ease;
}

.trend-point:hover .trend-point-dot,
.trend-point:focus .trend-point-dot,
.trend-point.selected .trend-point-dot {
  r: 7px;
  stroke-width: 3px;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.28));
}

.trend-empty {
  padding: 22px 12px;
  color: #7f8c8d;
  text-align: center;
  font-size: 0.9rem;
}

.trend-detail {
  margin-top: 14px;
  padding: 15px;
  border-radius: 13px;
  background: #ffffff;
  border: 1px solid #dbe4ee;
  box-shadow: 0 8px 20px rgba(31, 58, 95, 0.08);
  text-align: left;
}

.trend-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.trend-detail-kicker {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.trend-detail h3 {
  margin: 3px 0 2px;
  color: #1f3a5f;
  font-size: 1.05rem;
}

.trend-detail h3 span {
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.82em;
}

.trend-detail p {
  margin: 0;
  color: #7f8c8d;
  font-size: 0.82rem;
}

.trend-detail-close {
  appearance: none;
  border: 0;
  background: #eef2f7;
  color: #526170;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.trend-detail-close:hover {
  background: #e2e8f0;
  color: #1f3a5f;
}

.trend-detail-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.trend-detail-stats > div {
  padding: 9px 7px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #edf1f5;
  text-align: center;
}

.trend-detail-stats span {
  display: block;
  color: #7f8c8d;
  font-size: 0.7rem;
  font-weight: 700;
}

.trend-detail-stats strong {
  display: block;
  margin-top: 2px;
  color: #1f3a5f;
  font-size: 1rem;
}

@media (max-width: 640px) {
  .trend-panel {
    padding: 12px;
  }

  .trend-toolbar {
    gap: 6px;
  }

  .trend-filter {
    flex: 1 1 calc(50% - 6px);
    padding: 8px 10px;
  }

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

