.calio-fancy-chart {
  display: grid;
  gap: 20px;
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}

.calio-fancy-chart:hover,
.calio-fancy-chart:focus-within {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 26px 48px rgba(15, 23, 42, 0.12);
}

.calio-fancy-chart.skin-outline {
  background: #ffffff;
}

.calio-fancy-chart.skin-contrast {
  background: linear-gradient(180deg, #0f172a, #111827);
  border-color: rgba(148, 163, 184, 0.16);
}

.calio-fancy-chart.skin-contrast .calio-fancy-chart-title,
.calio-fancy-chart.skin-contrast .calio-fancy-chart-subtitle,
.calio-fancy-chart.skin-contrast .calio-fancy-chart-legend-item {
  color: #e5eefb;
}

.calio-fancy-chart.skin-glass {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
  backdrop-filter: blur(16px);
}

.calio-fancy-chart-header {
  display: grid;
  gap: 8px;
}

.calio-fancy-chart-preset-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.calio-fancy-chart-summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.calio-fancy-chart-summary-value {
  font-size: 13px;
  color: #0f172a;
}

.calio-fancy-chart-summary.trend-up .calio-fancy-chart-summary-value {
  color: #15803d;
}

.calio-fancy-chart-summary.trend-down .calio-fancy-chart-summary-value {
  color: #dc2626;
}

.calio-fancy-chart-summary-note {
  color: #64748b;
  font-weight: 600;
}

.calio-fancy-chart-kpis {
  display: grid;
  gap: 14px;
}

.calio-fancy-chart-kpis.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.calio-fancy-chart-kpis.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calio-fancy-chart-kpis.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.calio-fancy-chart-kpi {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.calio-fancy-chart-kpi-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.calio-fancy-chart-kpi-value {
  color: #0f172a;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}

.calio-fancy-chart-kpi-note {
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}

.calio-fancy-chart-kpi.trend-up .calio-fancy-chart-kpi-value {
  color: #15803d;
}

.calio-fancy-chart-kpi.trend-down .calio-fancy-chart-kpi-value {
  color: #dc2626;
}

.calio-fancy-chart.preset-finance .calio-fancy-chart-preset-badge,
.calio-fancy-chart.preset-finance .calio-fancy-chart-summary {
  background: rgba(21, 128, 61, 0.08);
  color: #15803d;
}

.calio-fancy-chart.preset-finance .calio-fancy-chart-kpi {
  background: rgba(240, 253, 244, 0.78);
}

.calio-fancy-chart.preset-product .calio-fancy-chart-preset-badge,
.calio-fancy-chart.preset-product .calio-fancy-chart-summary {
  background: rgba(217, 119, 6, 0.1);
  color: #b45309;
}

.calio-fancy-chart.preset-product .calio-fancy-chart-kpi {
  background: rgba(255, 251, 235, 0.82);
}

.calio-fancy-chart.preset-saas .calio-fancy-chart-preset-badge,
.calio-fancy-chart.preset-saas .calio-fancy-chart-summary {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

.calio-fancy-chart.preset-saas .calio-fancy-chart-kpi {
  background: rgba(245, 243, 255, 0.82);
}

.calio-fancy-chart.preset-analytics .calio-fancy-chart-kpi {
  background: rgba(239, 246, 255, 0.82);
}

.calio-fancy-chart-tools {
  display: flex;
  justify-content: flex-end;
}

.calio-fancy-chart-preview {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.calio-fancy-chart-preview-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
}

.calio-fancy-chart-preview-title {
  font-size: 0.95rem;
  line-height: 1.2;
}

.calio-fancy-chart-preview-meta {
  color: #475569;
  font-size: 0.78rem;
  font-weight: 600;
}

.calio-fancy-chart-preview-wrap {
  overflow-x: auto;
}

.calio-fancy-chart-preview-notes {
  display: grid;
  gap: 8px;
}

.calio-fancy-chart-preview-note {
  padding: 8px 10px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 12px;
  background: rgba(255, 247, 237, 0.92);
  color: #9a3412;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.calio-fancy-chart-preview table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
}

.calio-fancy-chart-preview th,
.calio-fancy-chart-preview td {
  padding: 8px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  font-size: 12px;
}

.calio-fancy-chart-preview th {
  color: #475569;
}

.calio-fancy-chart-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 10px 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #0f172a;
  cursor: pointer;
}

.calio-fancy-chart-table {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.calio-fancy-chart-table summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-weight: 700;
}

.calio-fancy-chart-table summary::-webkit-details-marker {
  display: none;
}

.calio-fancy-chart-table-wrap {
  overflow-x: auto;
  padding: 0 16px 16px;
}

.calio-fancy-chart-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.calio-fancy-chart-table th,
.calio-fancy-chart-table td {
  padding: 10px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  font-size: 13px;
}

.calio-fancy-chart-table th {
  color: #475569;
}

.calio-fancy-chart-title {
  margin: 0;
  color: #0f172a;
  font-size: clamp(1.25rem, 1.4vw, 1.8rem);
  line-height: 1.2;
}

.calio-fancy-chart-subtitle {
  max-width: 62ch;
  color: #64748b;
  font-size: 14px;
  line-height: 1.7;
}

.calio-fancy-chart-body {
  display: grid;
  gap: 18px;
}

.calio-fancy-chart.legend-right .calio-fancy-chart-body {
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: start;
}

.calio-fancy-chart.legend-right [data-legend] {
  order: 2;
  align-content: start;
}

.calio-fancy-chart.legend-top [data-legend] {
  order: -1;
}

.calio-fancy-chart-canvas-wrap {
  position: relative;
  min-height: 280px;
  height: 360px;
  padding: var(--calio-chart-pad, 12px);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
}

.calio-fancy-chart.skin-contrast .calio-fancy-chart-canvas-wrap {
  background: rgba(15, 23, 42, 0.42);
}

.calio-fancy-chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.calio-fancy-chart.engine-chartjs .calio-fancy-chart-canvas {
  cursor: default;
}

.calio-fancy-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.calio-fancy-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.calio-fancy-chart-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--legend-color, #2563eb);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--legend-color, #2563eb) 14%, transparent);
}

.calio-fancy-chart-empty {
  padding: 24px;
  border: 1px dashed rgba(148, 163, 184, 0.38);
  border-radius: 18px;
  color: #64748b;
  text-align: center;
}

.calio-fancy-chart-tooltip {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 0, 0) scale(0.98);
  transform-origin: left top;
  transition: opacity 140ms ease, transform 140ms ease;
  will-change: transform, opacity;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.26);
}

.calio-fancy-chart-tooltip.is-visible {
  opacity: 1;
}

.calio-fancy-chart-tooltip-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--tooltip-color, #2563eb);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tooltip-color, #2563eb) 14%, transparent);
}

@media (max-width: 767px) {
  .calio-fancy-chart.legend-right .calio-fancy-chart-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .calio-fancy-chart-kpis.cols-2,
  .calio-fancy-chart-kpis.cols-3,
  .calio-fancy-chart-kpis.cols-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .calio-fancy-chart {
    padding: 18px;
  }

  .calio-fancy-chart-canvas-wrap {
    min-height: 220px;
    height: 280px;
  }
}
