/* Token usage page (admin-tokens.html, js/admin-tokens.js, js/tk-charts.js) — Claude users only */
#tokens {
  /* categorical slots in a fixed order (validated light set); a colour always means the same entity */
  --tk-s1: #2a78d6; --tk-s2: #eb6834; --tk-s3: #1baf7a; --tk-s4: #eda100;
  --tk-s5: #e87ba4; --tk-s6: #008300; --tk-s7: #6250d6; --tk-s8: #e34948;
  --tk-neutral: #9a968d;
}
#tokens.is-dark {
  --tk-s1: #3987e5; --tk-s2: #d95926; --tk-s3: #199e70; --tk-s4: #c98500;
  --tk-s5: #d55181; --tk-s6: #008300; --tk-s7: #9085e9; --tk-s8: #e66767;
  --tk-neutral: #7c7a73;
}
.tk-h { margin: 28px 0 12px; font-size: 1.15rem; }
.tk-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.tk-grid > .card { min-width: 0; margin: 0; }
.tk-wide { grid-column: 1 / -1; }
.tk-chart .panel-title { flex-wrap: wrap; gap: 6px 8px; }
.tk-chart .panel-title .badge { margin-left: auto; font-weight: 600; }
.tk-no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font: 700 0.78rem var(--font-ui, inherit); }
.tk-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 12px 0 4px; }
.tk-tile { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.tk-tile strong { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tk-tile span { font-size: 0.8rem; color: var(--muted); }
.tk-summary { display: grid; gap: 4px 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); margin: 12px 0; }
.tk-summary p { margin: 0; padding-left: 14px; border-left: 3px solid var(--primary); font-size: 0.92rem; }
/* svg charts */
.tk-svg { display: block; width: 100%; height: auto; margin: 8px 0 4px; overflow: visible; }
.tk-svg--sq { max-width: 210px; }
.tk-svg .tk-gl { stroke: var(--border); stroke-width: 1; }
.tk-ax { fill: var(--muted); font: 9.5px var(--font-ui, sans-serif); }
.tk-center { fill: var(--text); font: 700 17px var(--font-ui, sans-serif); }
.tk-mark, .tk-slice, .tk-dot, .tk-cell { stroke: var(--surface); stroke-width: 1.5; }
.tk-dot { fill-opacity: 0.85; }
.tk-mark:hover, .tk-slice:hover, .tk-dot:hover, g:hover > .tk-cell { filter: brightness(1.12); stroke: var(--text); }
.tk-hit { fill: transparent; }
.tk-hit:hover { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.tk-cell-t { fill: #fff; font: 600 10.5px var(--font-ui, sans-serif); pointer-events: none; }
.tk-cell-v { font-weight: 400; opacity: 0.9; }
.tk-pie { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.tk-pie .tk-svg { flex: 0 1 210px; }
/* horizontal bars */
.tk-rows { display: grid; gap: 8px; margin: 10px 0 4px; }
.tk-row { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr) 5.5rem; gap: 10px; align-items: center; font-size: 0.86rem; }
.tk-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-row b { text-align: right; font-variant-numeric: tabular-nums; }
.tk-row b small { display: block; font-weight: 400; color: var(--muted); font-size: max(12px, 0.72rem); }
.tk-track { height: 12px; border-radius: 0 6px 6px 0; background: var(--surface-2); overflow: hidden; }
.tk-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
/* legends */
.tk-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.tk-legend--col { flex-direction: column; flex: 1 1 140px; }
.tk-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.tk-legend b { color: var(--text); font-weight: 600; margin-left: 4px; }
/* Excel-style heat grid */
.tk-heat { border-collapse: separate; border-spacing: 2px; font-size: max(12px, 0.68rem); font-variant-numeric: tabular-nums; margin: 8px 0; }
.tk-heat th { color: var(--muted); font-weight: 600; padding: 2px 4px; white-space: nowrap; text-align: left; }
.tk-heat td { min-width: 36px; height: 26px; padding: 0 4px; border-radius: 4px; text-align: right; color: var(--text); white-space: nowrap; }
.tk-heat td.is-dark { color: #fff; }
.tk-tip { position: fixed; z-index: 1000; max-width: 280px; padding: 6px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 0.8rem; pointer-events: none; box-shadow: var(--shadow); }
.tk-rule { margin-top: 10px; font-size: 0.82rem; color: var(--muted); }
.tk-rule summary { cursor: pointer; min-height: 32px; font-weight: 600; color: var(--text); }
.tk-rule p { margin: 6px 0 0; }
.tk-upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.tk-upload code { font-size: 0.8rem; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .tk-row { grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) 4.5rem; gap: 8px; }
}

/* ---------- 100 colour themes (js/tk-fun.js) ---------- */
#tokens { --tk-tint: 0%; }
#tokens .tk-chart, #tokens > .card { background: color-mix(in srgb, var(--tk-s1) var(--tk-tint), var(--surface)); }
.tk-chart .tk-no { background: color-mix(in srgb, var(--tk-s1) 22%, var(--surface-2)); color: var(--text); }
.tk-themes { margin-top: 14px; }
.tk-themes summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.tk-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; max-height: 320px; overflow-y: auto; padding: 4px; }
.tk-swatch { position: relative; display: flex; height: 44px; padding: 0; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--surface-2); }
.tk-swatch i { flex: 1 1 0; }
.tk-swatch span { position: absolute; right: 3px; bottom: 2px; padding: 0 4px; border-radius: 6px; background: var(--surface); color: var(--text); font: 700 max(12px, 0.62rem) var(--font-ui, sans-serif); }
.tk-swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--tk-s1); }
.tk-swatch:hover { transform: translateY(-2px); }

/* ---------- effects (off with Low graphics and reduced motion) ---------- */
.tk-motion .tk-chart { transition: transform 0.25s ease, box-shadow 0.25s ease; }
.tk-motion .tk-chart:hover { transform: translateY(-3px); box-shadow: 0 10px 28px color-mix(in srgb, var(--tk-s1) 22%, transparent); }
.tk-motion .tk-chart:not(.is-in) :is(.tk-svg, .tk-rows, .tk-heat, .tk-legend) { opacity: 0; }
.tk-motion .tk-chart.is-in .tk-svg .tk-mark { transform-box: fill-box; transform-origin: 50% 100%; animation: tk-grow 0.7s cubic-bezier(.2, .8, .2, 1) both; }
.tk-motion .tk-chart.is-in .tk-svg .tk-mark:nth-child(3n) { animation-delay: 0.08s; }
.tk-motion .tk-chart.is-in .tk-svg .tk-mark:nth-child(3n+1) { animation-delay: 0.16s; }
.tk-motion .tk-chart.is-in .tk-line { stroke-dasharray: 1; animation: tk-draw 1.2s ease-out both; }
.tk-motion .tk-chart.is-in .tk-fill { animation: tk-fade 1.2s ease-out both; }
.tk-motion .tk-chart.is-in .tk-svg--sq { animation: tk-spin 0.9s cubic-bezier(.2, .8, .2, 1) both; }
.tk-motion .tk-chart.is-in :is(.tk-cell, .tk-dot) { transform-box: fill-box; transform-origin: center; animation: tk-pop 0.6s cubic-bezier(.3, 1.4, .5, 1) both; }
.tk-motion .tk-chart.is-in .tk-track i { animation: tk-width 0.9s cubic-bezier(.2, .8, .2, 1) both; }
.tk-motion .tk-chart.is-in .tk-heat td { animation: tk-fade 0.6s ease both; }
.tk-motion .tk-chart.is-in .tk-heat tr:nth-child(2n) td { animation-delay: 0.1s; }
.tk-motion > .card:first-child { position: relative; }
.tk-motion > .card:first-child::before { content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: inherit; background: conic-gradient(from var(--tk-a, 0deg), var(--tk-s1), var(--tk-s2), var(--tk-s3), var(--tk-s7), var(--tk-s1)); animation: tk-ring 8s linear infinite; }
@property --tk-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes tk-grow { from { transform: scaleY(0); } }
@keyframes tk-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes tk-fade { from { opacity: 0; } }
@keyframes tk-spin { from { transform: rotate(-90deg) scale(0.6); opacity: 0; } }
@keyframes tk-pop { from { transform: scale(0); opacity: 0; } }
@keyframes tk-width { from { width: 0; } }
@keyframes tk-ring { to { --tk-a: 360deg; } }
.tk-confetti { position: fixed; inset: 0; z-index: 1001; pointer-events: none; overflow: hidden; }
.tk-confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: tk-fall linear both; }
@keyframes tk-fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); } }
@media (prefers-reduced-motion: reduce) { .tk-motion *, .tk-motion *::before { animation: none !important; transition: none !important; } }

/* ---------- two windows + Analysis pieces (js/admin-analysis.js) ---------- */
.tk-tabs { position: sticky; top: 64px; z-index: 5; display: flex; gap: 6px; padding: 6px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.tk-tab { flex: 1 1 0; display: grid; place-items: center; min-height: 44px; border-radius: 10px; color: var(--text); font-weight: 700; text-decoration: none; }
.tk-tab[aria-current="page"] { background: var(--tk-s1); color: #fff; }
.tk-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.tk-node { flex: 1 1 110px; display: grid; gap: 2px; justify-items: center; padding: 12px 8px; border-radius: 12px; background: color-mix(in srgb, var(--tk-s1) 14%, var(--surface-2)); text-align: center; }
.tk-node-i { font-size: 1.3rem; }
.tk-node b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.tk-node small { color: var(--muted); font-size: 0.78rem; }
.tk-arrow { color: var(--muted); font-weight: 700; }
.tk-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 6px; margin: 10px 0; }
.tk-checks span { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 0.86rem; }
.tk-checks .is-ok { box-shadow: inset 3px 0 0 #1f8f5f; }
.tk-checks .is-bad { box-shadow: inset 3px 0 0 #e34948; font-weight: 700; }
.tk-svg .tk-fit { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0.7; }
@media (max-width: 560px) { .tk-tabs { top: 56px; } .tk-arrow { display: none; } }
