@layer uniform.components {
u-chart[data-drawn] > table {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.u-chart-stacked {
  display: flex;
  flex-direction: column;
  gap: var(--u-space-4);
}

.u-chart-current { --u-chart-color: var(--u-color-chart-current); }

.u-chart-previous { --u-chart-color: var(--u-color-chart-previous); }

.u-chart-danger { --u-chart-color: var(--u-color-danger); }

.u-chart-info { --u-chart-color: var(--u-color-info); }

.u-chart-warning { --u-chart-color: var(--u-color-warning); }

.u-chart-success { --u-chart-color: var(--u-color-success); }

.u-chart-neutral { --u-chart-color: var(--u-color-border-input); }

.u-chart-plot {
  --u-chart-height: 200px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: var(--u-chart-height) auto;
  column-gap: var(--u-space-2);
  row-gap: var(--u-space-2);
  position: relative;
}

.u-chart-svg {
  display: block;
  grid-area: 1 / 2;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.u-chart-grid {
  fill: none;
  stroke: var(--u-color-chart-grid);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.u-chart-bar {
  fill: var(--u-chart-color, transparent);
  shape-rendering: crispEdges;
}

.u-chart-col .u-chart-bar { transition: opacity var(--u-motion-hover) var(--u-motion-ease); }

.u-chart-svg:has(.u-chart-col-active) .u-chart-col:not(.u-chart-col-active) .u-chart-bar { opacity: var(--u-chart-dim-opacity); }

.u-chart-hit { fill: transparent; }

.u-chart-guide {
  stroke: var(--u-color-border-input);
  stroke-width: 1px;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

.u-chart-col-active .u-chart-guide { opacity: 1; }

.u-chart-line {
  fill: none;
  stroke: var(--u-chart-color, transparent);
  stroke-width: 1.5px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.u-chart-area { stroke: none; }

.u-chart-fade-top {
  stop-color: var(--u-color-chart-fill);
  stop-opacity: var(--u-chart-fill-opacity);
}

.u-chart-fade-bottom {
  stop-color: var(--u-color-chart-fill);
  stop-opacity: 0;
}

.u-chart-axis {
  display: grid;
  color: var(--u-color-text-muted);
  font-family: var(--u-font-mono);
  font-size: var(--u-font-size-caption);
  font-variant-numeric: tabular-nums;
  line-height: var(--u-line-height-caption);
  white-space: nowrap;
}

.u-chart-axis-y {
  grid-area: 1 / 1;
  justify-items: end;
}

.u-chart-axis-x {
  display: flex;
  grid-area: 2 / 2;
  justify-content: space-between;
  gap: var(--u-space-4);
}

.u-chart-tick {
  grid-area: 1 / 1;
  position: relative;
}

.u-chart-axis-y .u-chart-tick {
  align-self: end;
  bottom: var(--u-chart-at, 0%);
  translate: 0 50%;
}


.u-chart-spark {
  display: block;
  width: 100%;
  height: 32px;
  overflow: visible;
}

.u-chart-stack {
  display: flex;
  height: 24px;
}

.u-chart-segment {
  flex: var(--u-chart-share, 1) 1 0;
  min-width: 2px;
  border-left: 2px solid var(--u-color-bg-surface);
  background: var(--u-chart-color, transparent);
}

.u-chart-segment:first-child { border-left: 0; }

.u-chart-meter {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  background: var(--u-color-chart-track);
  appearance: none;
}

.u-chart-meter::-webkit-meter-bar {
  height: 8px;
  border: 0;
  border-radius: 0;
  background: var(--u-color-chart-track);
}

.u-chart-meter::-webkit-meter-optimum-value,
.u-chart-meter::-webkit-meter-suboptimum-value,
.u-chart-meter::-webkit-meter-even-less-good-value {
  border-radius: 0;
  background: var(--u-color-chart-current);
}

.u-chart-meter::-moz-meter-bar {
  border-radius: 0;
  background: var(--u-color-chart-current);
}

.u-chart-legend {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--u-space-4);
  row-gap: var(--u-space-2);
  margin: 0;
  padding: 0;
  font-size: var(--u-font-size-small);
  line-height: var(--u-line-height-small);
  list-style: none;
}

u-chart > .u-chart-legend { margin-block-end: var(--u-space-4); }

.u-chart-legend > li {
  display: flex;
  align-items: center;
  gap: var(--u-space-2);
}

.u-chart-key {
  display: inline-flex;
  align-items: center;
  gap: var(--u-space-2);
  color: var(--u-color-text-default);
  white-space: nowrap;
}

.u-chart-key::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--u-chart-color, transparent);
}

.u-chart-key-line::before {
  width: 12px;
  height: 2px;
}

.u-chart-tooltip {
  display: grid;
  gap: var(--u-space-1);
  width: max-content;
  padding: var(--u-space-2) var(--u-space-4);
  border: 1px solid var(--u-color-border);
  background: var(--u-color-bg-surface);
  color: var(--u-color-text-default);
  box-shadow: var(--u-shadow-float);
  font-size: var(--u-font-size-small);
  line-height: var(--u-line-height-small);
}

.u-chart-tooltip[hidden] { display: none; }

.u-chart-tooltip > * { margin: 0; }

.u-chart-tooltip-value {
  font-family: var(--u-font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.u-chart-tooltip-label {
  color: var(--u-color-text-muted);
  font-family: var(--u-font-mono);
}

u-chart:defined > .u-chart-plot:has(> .u-chart-tooltip) { padding-top: var(--u-chart-lane); }

.u-chart-plot .u-chart-tooltip {
  position: absolute;
  top: calc(var(--u-chart-lane) - var(--u-space-2));
  left: 0;
  z-index: 10;
  translate: 0 -100%;
  pointer-events: none;
}

.u-chart-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--u-space-4);
  margin: 0;
  padding-top: var(--u-space-4);
  border-top: 1px solid var(--u-color-divider);
  color: var(--u-color-text-muted);
  font-size: var(--u-font-size-caption);
  line-height: var(--u-line-height-caption);
}

.u-chart-empty {
  display: flex;
  align-items: center;
  min-height: var(--u-chart-height, 200px);
  margin: 0;
  color: var(--u-color-text-muted);
  font-size: var(--u-font-size-small);
}

.u-chart-empty-plot {
  min-height: calc(var(--u-chart-lane) + var(--u-chart-height, 200px) + var(--u-space-2) + var(--u-font-size-caption) * var(--u-line-height-caption));
}

.u-chart-loading {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: var(--u-space-2);
  height: var(--u-chart-height, 200px);
  margin: 0;
  overflow: hidden;
  border-block: 1px solid var(--u-color-chart-grid);
}

.u-chart-loading-line > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: var(--u-color-chart-track);
}

.u-chart-stack > .u-shimmer,
.u-chart-spark > .u-shimmer {
  height: 100%;
  margin: 0;
}

.u-chart-meter-loading > .u-shimmer {
  height: 8px;
  margin: 0;
}

.u-chart-loading > span {
  flex: 1;
  height: var(--u-chart-at, 50%);
  background: var(--u-color-chart-track);
}

.u-chart-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--u-color-shimmer), transparent);
  translate: -100% 0;
  animation: u-shimmer var(--u-motion-shimmer) var(--u-motion-ease) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .u-chart-loading::after { display: none; }
}
}
