/* The staff dashboard's visuals: KPI cards, rings, bars, donuts and funnel. Colours come from the app's own tokens, so light and dark both work. */

.ch-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.ch-kpi {
  position: relative; overflow: hidden; background: var(--ml-surface); border: 1px solid var(--ml-border); border-radius: 16px; padding: 18px 18px 16px;
  box-shadow: var(--ml-shadow-1); transition: transform .2s var(--ml-ease), box-shadow .2s var(--ml-ease), border-color .2s; animation: ch-rise .5s var(--ml-ease) backwards;
}
.ch-kpi::after { content: ""; position: absolute; inset-inline-end: -40px; top: -50px; width: 140px; height: 140px; border-radius: 50%; background: var(--c); opacity: .07; }
.ch-kpi.is-click { cursor: pointer; }
.ch-kpi.is-click:hover { transform: translateY(-3px); box-shadow: var(--ml-shadow-2); border-color: color-mix(in srgb, var(--c) 45%, var(--ml-border)); }
.ch-kpi__top { display: flex; align-items: center; gap: 10px; }
.ch-kpi__icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c); box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 40%, transparent); }
.ch-kpi__label { font-size: 13px; font-weight: 600; color: var(--ml-text-2); }
.ch-kpi__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.ch-kpi__value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; color: var(--ml-text); font-variant-numeric: tabular-nums; }
.ch-kpi__hint { font-size: 12px; color: var(--ml-text-3); margin-inline-start: 6px; }
.ch-trend { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.ch-trend.is-good { color: #15803D; background: rgba(22, 163, 74, .13); }
.ch-trend.is-bad { color: #B91C1C; background: rgba(220, 38, 38, .12); }
[data-theme="dark"] .ch-trend.is-good { color: #4ADE80; }
[data-theme="dark"] .ch-trend.is-bad { color: #F87171; }

.ch-ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ch-ring svg { transform: rotate(-90deg); }
.ch-ring__arc { transition: stroke-dasharray 1s var(--ml-ease); animation: ch-fade .8s ease backwards; }
.ch-ring__v { position: absolute; font-weight: 800; color: var(--ml-text); letter-spacing: -.02em; }

.ch-chart { position: relative; width: 100%; }
.ch-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid { stroke: var(--ml-border); stroke-dasharray: 3 5; }
.ch-axis { fill: var(--ml-text-3); font: 500 11px Inter, sans-serif; }
.ch-bar { transform-box: fill-box; transform-origin: bottom; animation: ch-grow .7s var(--ml-ease) backwards; transition: filter .15s, opacity .15s; }
.ch-bar.is-hot { filter: brightness(1.15) saturate(1.2); }
.ch-tip {
  position: absolute; transform: translate(-50%, -125%); pointer-events: none; background: var(--ml-text); color: var(--ml-surface); padding: 7px 11px; border-radius: 10px;
  font-size: 12.5px; white-space: nowrap; box-shadow: var(--ml-shadow-3); z-index: 5; animation: ch-fade .12s ease-out;
}
.ch-tip small { display: block; opacity: .7; font-weight: 500; }

.ch-donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ch-donut { position: relative; width: 170px; height: 170px; flex: none; }
.ch-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ch-donut__seg { transition: stroke-width .18s; animation: ch-fade .8s ease backwards; cursor: pointer; }
.ch-donut__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 0 28px; pointer-events: none; }
.ch-donut__center b { font-size: 22px; font-weight: 800; letter-spacing: -.03em; color: var(--ml-text); line-height: 1.1; }
.ch-donut__center span { font-size: 11.5px; color: var(--ml-text-3); font-weight: 600; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 4px; }
.ch-legend__row { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; font: 500 13px Inter, sans-serif; color: var(--ml-text); padding: 6px 8px; border-radius: 8px; cursor: pointer; text-align: start; }
.ch-legend__row i { width: 10px; height: 10px; border-radius: 4px; flex: none; }
.ch-legend__row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-legend__row b { font-variant-numeric: tabular-nums; color: var(--ml-text-2); }
.ch-legend__row:hover, .ch-legend__row.is-hot { background: var(--ml-hover); }
.ch-legend__row.is-off { opacity: .4; text-decoration: line-through; }

.ch-funnel { display: flex; flex-direction: column; gap: 10px; }
.ch-funnel__row { display: grid; grid-template-columns: 120px 1fr 64px; align-items: center; gap: 12px; font-size: 13px; }
.ch-funnel__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-funnel__track { height: 26px; border-radius: 8px; background: var(--ml-surface-2); overflow: hidden; }
.ch-funnel__fill { height: 100%; border-radius: 8px; display: flex; align-items: center; justify-content: flex-end; padding-inline: 8px; color: #fff; font-size: 11.5px; font-weight: 700; background: linear-gradient(90deg, var(--ml-primary), color-mix(in srgb, var(--ml-primary) 55%, #06B6D4)); animation: ch-width .8s var(--ml-ease) backwards; min-width: 28px; }
.ch-funnel__pct { text-align: end; color: var(--ml-text-2); font-variant-numeric: tabular-nums; }

.ch-targets { display: flex; flex-wrap: wrap; gap: 18px 26px; justify-content: space-around; }
.ch-target { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 110px; text-align: center; }
.ch-target b { font-size: 13px; }
.ch-target small { color: var(--ml-text-3); font-size: 11.5px; }

.ch-pair { display: flex; flex-direction: column; gap: 14px; }
.ch-pair__row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.ch-pair__bars { display: flex; flex-direction: column; gap: 4px; }
.ch-pair__bar { height: 9px; border-radius: 99px; background: var(--ml-primary); animation: ch-width .8s var(--ml-ease) backwards; min-width: 3px; }
.ch-pair__bar.is-prev { background: var(--ml-border-strong); height: 6px; }
.ch-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ml-text-2); margin-inline-end: 14px; }
.ch-key i { width: 10px; height: 10px; border-radius: 4px; background: var(--ml-primary); }
.ch-key i.is-prev { background: var(--ml-border-strong); }

@keyframes ch-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes ch-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ch-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes ch-width { from { width: 0; } }
@media (prefers-reduced-motion: reduce) { .ch-kpi, .ch-bar, .ch-funnel__fill, .ch-pair__bar, .ch-donut__seg, .ch-ring__arc { animation: none !important; transition: none !important; } }
@media (max-width: 600px) { .ch-funnel__row { grid-template-columns: 90px 1fr 52px; } .ch-donut { width: 150px; height: 150px; } }
