.cbd-widget {
  border: 1px solid #e8ecf3;
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
  background: #ffffff;
  color: #1f2937;
}

.cbd-cards {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
}

.cbd-cards--two {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.cbd-card {
  border: 1px solid #e8ecf3;
  border-radius: 10px;
  padding: 12px;
  background: #f9fbff;
}

.cbd-card h3,
.cbd-card-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
}

.cbd-value {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 1.15rem;
}

.cbd-value-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cbd-value-line .cbd-value {
  margin: 0;
  line-height: 1.15;
}

.cbd-change-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 6px 10px;
  min-height: 30px;
  box-sizing: border-box;
  line-height: 1;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.cbd-change-pill--up {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.15);
}

.cbd-change-pill--down {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.15);
}

.cbd-meta,
.cbd-updated {
  margin: 0;
  font-size: 0.95rem;
  color: #4b5563;
}

.cbd-updated {
  margin-top: 2px;
}

.cbd-positive {
  color: #16a34a;
}

.cbd-negative {
  color: #dc2626;
}

.cbd-shares-summary {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: #374151;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 16px;
  text-align: center;
}

.cbd-share-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cbd-share-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.cbd-history-table-wrap {
  overflow-x: auto;
  margin: 0 0 12px;
}

.cbd-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.cbd-history-table th,
.cbd-history-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
}

.cbd-history-table td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cbd-graph-grid {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
}

.cbd-range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.cbd-range-tab {
  border: 1px solid #d3dae6;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-size: 0.88rem;
  line-height: 1;
  padding: 8px 10px;
  cursor: pointer;
}

.cbd-range-tab--active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.cbd-graph {
  min-height: 280px;
  border: 1px dashed #d3dae6;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fcfdff;
  margin: 0 0 12px;
}

.cbd-graph-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
}

.cbd-graph-fallback {
  margin: 0;
  color: #6b7280;
  text-align: center;
}

.cbd-graph--chart {
  position: relative;
  justify-content: flex-start;
  align-items: stretch;
  padding: 10px;
}

.cbd-chart-canvas {
  display: block;
  width: 100%;
  height: 300px;
}

.cbd-chart-tooltip {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.9);
  color: #ffffff;
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 6px 8px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.cbd-graph--donut {
  align-items: flex-start;
}

.cbd-donut-wrap {
  width: 100%;
  display: grid;
  gap: 10px;
  grid-template-columns: 128px 1fr;
  align-items: center;
}

.cbd-donut-svg {
  width: 128px;
  height: 128px;
  display: block;
}

.cbd-donut-legend {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.cbd-donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #374151;
}

.cbd-donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.cbd-widget--error {
  border: 1px solid #f8c9c9;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff5f5;
  color: #8f2f2f;
}

@media (min-width: 768px) {
  .cbd-cards--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .cbd-graph-grid .cbd-graph:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 540px) {
  .cbd-donut-wrap {
    grid-template-columns: 1fr;
  }

  .cbd-donut-svg {
    margin: 0 auto;
  }

  .cbd-chart-tooltip {
    font-size: 0.72rem;
    padding: 5px 7px;
    white-space: normal;
    max-width: calc(100% - 12px);
    line-height: 1.25;
  }
}
