/* qk-charts.css - UI kit chart look (dika-ui-kit "viz" engine: cx-*, vz-*, chart-tip) mapped to the
   site tokens. Loaded by every app page that has charts. Nothing here restyles other components. */
:root {
  --qk-1: oklch(0.22 0.005 260); --qk-2: oklch(0.48 0.005 260); --qk-3: oklch(0.64 0.005 260); --qk-4: oklch(0.78 0.004 260);
  --qk-5: oklch(0.89 0.003 260); --qk-6: oklch(0.6 0.13 250); --qk-grid: oklch(0.93 0.002 260); --qk-axis: #71717a; --qk-dash: #a1a1aa;
  --qk-card: var(--surface);
}
:root[data-theme="dark"] {
  --qk-1: oklch(0.95 0.003 260); --qk-2: oklch(0.76 0.004 260); --qk-3: oklch(0.58 0.005 260); --qk-4: oklch(0.44 0.005 260);
  --qk-5: oklch(0.32 0.005 260); --qk-6: oklch(0.72 0.12 250); --qk-grid: oklch(0.27 0.004 260); --qk-axis: #a1a1aa; --qk-dash: #71717a;
}

/* ---------- containers ---------- */
.qk-card { display: flex; flex-direction: column; min-width: 0; }
.qk-card > .qk-box.is-fill, .qk-card > .qk-fill { flex: 1 1 0; min-height: var(--qk-h, 220px); }
.qk-bar { display: flex; align-items: center; justify-content: flex-start; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.qk-bar .qk-hint { color: var(--text-2); font-size: .78rem; font-weight: 500; }
.qk-sub { margin: -6px 0 8px; color: var(--text-2); font-size: .78rem; }
.qk-box { position: relative; width: 100%; height: var(--qk-h, 220px); min-width: 0; }
.qk-box.is-fill, .qk-box--auto { height: auto; }
.qk-box > svg.chart { position: absolute; left: 0; top: 0; }
.chart.viz { display: block; max-width: 100%; overflow: visible; font-family: inherit; touch-action: pan-y; }
.qk-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.qk-stats div { display: grid; gap: 1px; min-width: 0; }
.qk-stats small { color: var(--text-2); font-size: .72rem; font-weight: 500; }
.qk-stats b { font-size: 1rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------- axes, grid, lines (kit cx-*) ---------- */
.cx-grid { stroke: var(--qk-grid); stroke-width: 1; shape-rendering: crispEdges; }
.cx-grid.is-base { stroke: var(--line-2); }
.cx-ax { fill: var(--qk-axis); font-size: 10.5px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.cx-hit { fill: transparent; }
.chart.viz .cx-cross, .chart.viz .cx-dot { opacity: 0; }
.cx-cross { stroke: var(--qk-dash); stroke-width: 1; stroke-dasharray: 3 3; shape-rendering: crispEdges; }
.cx-dot { fill: var(--surface); stroke: var(--c, var(--qk-1)); stroke-width: 2; pointer-events: none; }
.cx-line { fill: none; stroke: var(--c); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: cx-draw 1100ms cubic-bezier(.22, 1, .36, 1) backwards; animation-delay: calc(var(--i, 0) * 120ms); }
.cx-line.is-dash { stroke-dasharray: 4 4; stroke-width: 1.5; animation: cx-fade 700ms ease 300ms backwards; }
.cx-area { fill: var(--c); fill-opacity: .07; stroke: none; animation: cx-fade 900ms ease 250ms backwards; }
.cx-end { fill: var(--c, var(--qk-1)); stroke: var(--surface); stroke-width: 2; animation: cx-pop 420ms cubic-bezier(.34, 1.56, .64, 1) 900ms backwards; transform-box: fill-box; transform-origin: center; }
.cx-stack { fill: var(--c); stroke: var(--surface); stroke-width: 1; transform-origin: 50% 100%; transform-box: fill-box; animation: cx-rise 800ms cubic-bezier(.22, 1, .36, 1) backwards; animation-delay: calc(var(--i) * 70ms); }
.cx-bar { fill: var(--c, var(--qk-3)); transform-origin: 50% 100%; transform-box: fill-box; animation: cx-rise 640ms cubic-bezier(.22, 1, .36, 1) backwards; animation-delay: calc(var(--i) * 18ms); transition: opacity 160ms; }
.cx-bar.is-dim { opacity: .35; }
.cx-stack--col { stroke: var(--surface); stroke-width: 1; }
.cx-band { fill: var(--surface-2); opacity: 0; transition: opacity 140ms; pointer-events: none; }
@keyframes cx-draw { from { stroke-dashoffset: 1; } }
@keyframes cx-fade { from { opacity: 0; } }
@keyframes cx-rise { from { transform: scaleY(0); } }
@keyframes cx-pop { from { transform: scale(0); } }
.chart.viz.is-static *, .qk-box.is-drawn .is-static * { animation: none !important; }

/* ---------- tooltip (kit chart-tip) ---------- */
.chart-tip { position: absolute; z-index: 5; min-width: 150px; padding: 8px 10px; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--sh-2); font-size: .75rem; line-height: 1.35; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity 120ms, transform 160ms cubic-bezier(.22, 1, .36, 1), left 110ms cubic-bezier(.22, 1, .36, 1), top 110ms cubic-bezier(.22, 1, .36, 1); }
.chart-tip.is-on { opacity: 1; transform: none; }
.chart-tip > b { display: block; margin-bottom: 4px; font-weight: 600; }
.chart-tip > b:last-child { margin-bottom: 0; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; color: var(--text-2); }
.chart-tip .tip-row i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.chart-tip .tip-row i.is-dash { height: 0; width: 10px; border-top: 2px dashed var(--c); background: none; border-radius: 0; }
.chart-tip .tip-row b { margin-left: auto; padding-left: 16px; color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.chart-tip .tip-row--sum { border-top: 1px solid var(--line); padding-top: 5px; margin-top: 5px; color: var(--text); }

/* ---------- legend ---------- */
.vz-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: .75rem; color: var(--text-2); }
.vz-leg { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 2px 0; color: inherit; font: inherit; transition: opacity 200ms, color 150ms; }
button.vz-leg { cursor: pointer; }
button.vz-leg:hover { color: var(--text); }
.vz-leg.is-off { opacity: .4; }
.vz-leg i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); flex: none; }
.vz-leg i.is-line { height: 2px; width: 14px; border-radius: 1px; }
.vz-leg b { color: var(--text); font-weight: 500; margin-left: 2px; font-variant-numeric: tabular-nums; }

/* ---------- ranked list (kit vz-hbar) ---------- */
.vz-hbar { display: grid; gap: 4px; position: relative; }
.vz-hbar__r { display: grid; grid-template-columns: minmax(84px, 150px) minmax(0, 1fr) 64px; align-items: center; gap: 12px; padding: 5px 8px; margin: 0 -8px; border-radius: 8px; font-size: .84rem; animation: cx-fade 420ms ease backwards; animation-delay: calc(var(--i) * 40ms); transition: background 150ms; }
.vz-hbar__r.is-on { background: var(--surface-2); }
.vz-hbar__l { display: grid; min-width: 0; line-height: 1.25; }
.vz-hbar__l b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vz-hbar__l small { font-size: .68rem; color: var(--text-2); }
.vz-hbar__t { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.vz-hbar__t i { display: block; height: 100%; width: var(--w); border-radius: 3px; background: var(--qk-1); transform-origin: left; animation: qk-grow 900ms cubic-bezier(.22, 1, .36, 1) backwards; animation-delay: calc(100ms + var(--i) * 50ms); }
.vz-hbar__r:nth-child(n+4) .vz-hbar__t i { background: var(--qk-3); }
.vz-hbar__r b.num { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
@keyframes qk-grow { from { transform: scaleX(0); } }

/* ---------- donut (kit vz-donut) ---------- */
.vz-donut { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 22px; position: relative; }
.vz-donut__c { position: relative; width: 150px; height: 150px; flex: none; }
.vz-donut__svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.cx-seg { fill: none; stroke: var(--c); stroke-width: 12; transition: stroke-width 260ms cubic-bezier(.34, 1.56, .64, 1), opacity 200ms; animation: seg-in 1000ms cubic-bezier(.22, 1, .36, 1) backwards; animation-delay: calc(var(--i) * 80ms); cursor: pointer; }
@keyframes seg-in { from { stroke-dasharray: 0 100; } }
.is-focus .cx-seg { opacity: .3; }
.is-focus .cx-seg.is-on { opacity: 1; stroke-width: 15; }
.vz-donut__mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; pointer-events: none; }
.vz-donut__mid small { font-size: .72rem; color: var(--text-2); }
.vz-donut__mid b { font-size: 1.5rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.vz-donut__leg { display: grid; gap: 1px; min-width: 130px; flex: 1 1 130px; max-width: 260px; }
.vz-dleg { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: .84rem; text-align: left; color: var(--text); cursor: pointer; transition: background 150ms; }
.vz-dleg i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.vz-dleg span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vz-dleg b { font-size: .78rem; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.vz-dleg.is-on { background: var(--surface-2); }

/* ---------- heat table (kit vz-ht) ---------- */
.vz-ht { display: grid; grid-template-columns: 34px repeat(var(--cols), minmax(0, 1fr)); gap: 3px; position: relative; }
.vz-ht__h { font-size: .66rem; color: var(--qk-axis); text-align: center; align-self: center; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: visible; }
.vz-ht__rh { text-align: left; font-size: .7rem; color: var(--qk-axis); align-self: center; }
.vz-ht i { height: 22px; border-radius: 4px; background: color-mix(in oklab, var(--qk-1) calc(var(--k) * 88%), var(--surface-3)); animation: cx-fade 380ms ease backwards; animation-delay: var(--d); transition: transform 200ms cubic-bezier(.34, 1.56, .64, 1); cursor: pointer; }
.vz-ht i.is-on { transform: scale(1.18); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--qk-1); position: relative; z-index: 1; }
.vz-ht__scale { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; font-size: .7rem; color: var(--qk-axis); }
.vz-ht__scale > i { width: 90px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--surface-3), var(--qk-1)); }

/* ---------- KPI sparkline ---------- */
.ap-kpi { overflow: visible; }
.qk-card > .qk-center { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; }
.qk-center > .vz-donut { width: 100%; }
.qk-spark { position: relative; width: 100%; height: 36px; margin-top: 8px; }
.qk-spark > svg { position: absolute; left: 0; top: 0; overflow: visible; display: block; cursor: crosshair; }
.qk-spark .cx-line { stroke-width: 1.6; }
.qk-spark .chart-tip { min-width: 0; }

/* ---------- live scans (recent scans list, kit table look) ---------- */
.qk-live { display: flex; flex-direction: column; gap: 0; flex: 1 1 auto; min-height: 0; }
.qk-live__h, .qk-live__r { display: grid; grid-template-columns: 42px minmax(0, 1.4fr) minmax(0, 1.1fr) 64px; align-items: center; gap: 10px; padding: 8px 4px; }
.qk-live__h { font-size: .68rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.qk-live__r { font-size: .82rem; border-bottom: 1px solid var(--line); border-radius: 0; }
.qk-live__r:last-child { border-bottom: 0; }
.qk-live__r:hover { background: var(--surface-2); }
.qk-live__t { font-variant-numeric: tabular-nums; color: var(--text-2); }
.qk-live__c { display: flex; align-items: center; gap: 8px; min-width: 0; }
.qk-live__c > span { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.qk-live__c .qq-ic { width: 14px; height: 14px; }
.qk-live__c b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qk-live__p { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qk-live__d { text-align: right; color: var(--text-2); }
.qk-live .ap-empty { flex: 1; align-content: center; }
@media (max-width: 560px) { .qk-live__h, .qk-live__r { grid-template-columns: 40px minmax(0, 1fr) 62px; } .qk-live__p, .qk-live__h span:nth-child(3) { display: none; } }

/* KPI delta that went down */
.ap-kpi em.is-down { color: var(--danger, #b42318); }
.ap-kpi em.is-down .qq-ic { transform: scaleY(-1); }

/* ---------- misc ---------- */
.qk-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
.qk-ctl .qk-hint { color: var(--text-2); font-size: .8rem; font-weight: 500; }
@media (max-width: 560px) { .qk-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .qk-stats b { font-size: .9rem; } }
@media (prefers-reduced-motion: reduce) { .chart-tip, .cx-seg, .vz-ht i { transition: none; } .cx-line, .cx-area, .cx-bar, .cx-end, .vz-hbar__r, .vz-hbar__t i, .vz-ht i, .cx-seg { animation: none !important; } }

.ap-trend .qk-spark { position: relative; width: 74px; height: 24px; margin: 0; flex: none; }
