/* Toolkit: shared styles for the interactive tools. Every class is prefixed tk- so nothing
   collides with site.css. The same file is inlined into each tool's downloadable copy. */
.tk {
  --tk-good: #34D399; --tk-warn: #FBBF24; --tk-serious: #FB923C; --tk-crit: #F87171;
  --tk-tint-empty: 18%; --tk-tint-full: 46%;
  display: flex; flex-direction: column; gap: var(--s3); font-size: .9375rem; line-height: 1.5;
}
.tk h2, .tk h3 { margin: 0; }
.tk h2 { font-size: 1.0625rem; letter-spacing: -.01em; }
.tk p { margin: 0; }
.tk button, .tk select, .tk input, .tk textarea { font: inherit; color: inherit; }
.tk-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-muted { color: var(--color-muted); font-size: .8125rem; }
.tk-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: space-between; }
.tk-meta { color: var(--color-muted); font: 500 .8125rem var(--font-mono); letter-spacing: .02em; }
.tk-meta b { color: var(--color-text); font-weight: 500; }

.tk-tabs { display: inline-flex; gap: 4px; background: var(--color-surface); border: 1px solid var(--color-border); padding: 4px; border-radius: 999px; }
.tk-tabs { max-width: 100%; overflow-x: auto; }
.tk-tabs a { white-space: nowrap; padding: 7px 16px; border-radius: 999px; text-decoration: none; color: var(--color-muted); font-weight: 500; font-size: .875rem; }
.tk-tabs a[aria-current="page"] { background: var(--color-primary); color: var(--color-button-text); font-weight: 600; }

.tk-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--s3); min-width: 0; }
.tk-card__head { display: flex; flex-wrap: wrap; gap: var(--s1); justify-content: space-between; align-items: flex-start; margin-bottom: var(--s2); }
.tk-sub { font-size: .8125rem; color: var(--color-muted); margin-top: 2px; }
.tk-headline { border-left: 4px solid var(--color-primary); }
.tk-headline p:first-child { font: 700 clamp(1.125rem, 2.4vw, 1.5rem)/1.3 var(--font-heading); color: var(--color-heading); max-width: 36em; text-wrap: balance; }
.tk-headline .tk-foot { margin-top: var(--s1); font-size: .8125rem; color: var(--color-muted); }

.tk-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.tk-kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-top: 3px solid var(--color-border); border-radius: var(--radius); padding: 14px var(--s2); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-kpi__lab { font-size: .8125rem; color: var(--color-muted); }
.tk-kpi__val { font: 800 2.125rem/1.1 var(--font-heading); color: var(--color-heading); }
.tk-kpi__delta { font-size: .78rem; color: var(--color-muted); overflow-wrap: anywhere; }
.tk-kpi--alert { border-top-color: var(--tk-crit); }
.tk-kpi--watch { border-top-color: var(--tk-warn); }
.tk-kpi--calm { border-top-color: var(--tk-good); }

.tk-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3); }
.tk-seg { display: inline-flex; background: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 3px; }
.tk-seg button { border: 0; background: none; padding: 5px 11px; border-radius: 6px; font-size: .8125rem; cursor: pointer; color: var(--color-muted); }
.tk-seg button[aria-pressed="true"] { background: var(--color-surface-hover); color: var(--color-heading); font-weight: 600; }

/* status fills: a status colour mixed into the surface, strength chosen by a t- class */
.tk-b-low { background: color-mix(in srgb, var(--tk-good) var(--tk-t, 60%), var(--color-surface)); }
.tk-b-med { background: color-mix(in srgb, var(--tk-warn) var(--tk-t, 60%), var(--color-surface)); }
.tk-b-high { background: color-mix(in srgb, var(--tk-serious) var(--tk-t, 60%), var(--color-surface)); }
.tk-b-crit { background: color-mix(in srgb, var(--tk-crit) var(--tk-t, 60%), var(--color-surface)); }
.tk-b-none { background: var(--color-surface-hover); }
.tk-t-empty { --tk-t: var(--tk-tint-empty); }
.tk-t-full { --tk-t: var(--tk-tint-full); }
.tk-t-pill { --tk-t: 30%; }
.tk-t-solid { --tk-t: 100%; }

.tk-heat { display: grid; grid-template-columns: auto repeat(5, minmax(0, 1fr)); gap: 4px; }
.tk-ax { font-size: .72rem; color: var(--color-muted); display: flex; align-items: center; justify-content: center; text-align: center; padding: 2px 4px; }
.tk-ax--y { justify-content: flex-end; min-width: 78px; text-align: right; }
.tk-ax b { font-weight: 500; color: var(--color-text); }
.tk-cell { aspect-ratio: 1.5 / 1; min-height: 40px; border: 0; border-radius: 6px; cursor: pointer; font: 800 1.1875rem var(--font-heading); color: var(--color-heading); display: flex; align-items: center; justify-content: center; }
.tk-cell:hover { filter: brightness(1.15); }
.tk-cell[aria-pressed="true"] { outline: 3px solid var(--color-heading); outline-offset: 1px; }
.tk-cell--empty { cursor: default; font-size: 0; }
.tk-cell--empty:hover { filter: none; }
.tk-axname { font-size: .75rem; color: var(--color-muted); font-weight: 600; text-align: center; margin-top: var(--s1); }
.tk-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .78rem; color: var(--color-muted); }
.tk-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tk-link { background: none; border: 0; padding: 0; color: var(--color-primary); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: .8125rem; }

.tk-stack { display: flex; flex-direction: column; gap: 10px; }
.tk-dec { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--color-background); }
.tk-dec__ask { font-weight: 600; color: var(--color-heading); }
.tk-dec__why { font-size: .8125rem; color: var(--color-muted); }
.tk-tags { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: .78rem; color: var(--color-muted); }
.tk-pill { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: var(--color-heading); white-space: nowrap; }
.tk-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.tk-tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--color-surface-hover); color: var(--color-text); white-space: nowrap; }
.tk-tag--over { background: color-mix(in srgb, var(--tk-crit) 30%, var(--color-surface)); color: var(--color-heading); font-weight: 600; }
.tk-tag--ok { background: color-mix(in srgb, var(--tk-good) 26%, var(--color-surface)); color: var(--color-heading); font-weight: 600; }

.tk-risk { border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-background); overflow: hidden; }
.tk-risk > button { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 12px; align-items: stretch; }
.tk-risk > button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.tk-risk__main { padding: 11px 0; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tk-risk__title { font-weight: 600; color: var(--color-heading); }
.tk-risk__side { padding: 11px 14px 11px 0; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 3px; font-size: .78rem; color: var(--color-muted); }
.tk-score { font: 800 1.375rem/1 var(--font-heading); color: var(--color-heading); }
.tk-detail { margin: 0; padding: 12px 14px 14px 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; font-size: .84rem; border-top: 1px dashed var(--color-border); }
.tk-detail dt { font: 500 .7rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--color-muted); }
.tk-detail dd { margin: 2px 0 0; }
.tk-prog { height: 6px; background: var(--color-surface-hover); border-radius: 3px; overflow: hidden; margin-top: 6px; min-width: 70px; }
.tk-prog i { display: block; height: 100%; width: 0; background: var(--color-primary); border-radius: 3px; }

.tk-bars { display: flex; flex-direction: column; gap: 9px; }
.tk-bar { display: grid; grid-template-columns: 124px minmax(0, 1fr) 26px; gap: 10px; align-items: center; font-size: .8125rem; }
.tk-bar__track { display: flex; gap: 2px; height: 14px; }
.tk-bar__track i { display: block; height: 100%; width: 0; border-radius: 0 4px 4px 0; min-width: 0; }
.tk-s-a { background: var(--color-primary); }
.tk-s-b { background: color-mix(in srgb, var(--color-primary) 28%, var(--color-surface)); }
.tk-trend { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding-top: 18px; border-bottom: 1px solid var(--color-border); }
.tk-trend__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.tk-trend__bar { width: 100%; max-width: 46px; height: 0; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--color-primary) 32%, var(--color-surface)); }
.tk-trend__col--now .tk-trend__bar { background: var(--color-primary); }
.tk-trend__v { font-size: .78rem; font-weight: 600; color: var(--color-heading); }
.tk-trendx { display: flex; gap: 10px; margin-top: 6px; }
.tk-trendx span { flex: 1; text-align: center; font-size: .75rem; color: var(--color-muted); }

#tk-tip { position: fixed; z-index: 9; pointer-events: none; background: var(--color-heading); color: var(--color-background); font-size: .78rem; padding: 6px 9px; border-radius: 6px; max-width: 260px; display: none; }

.tk-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tk-input, .tk select, .tk-form input, .tk-form textarea { background: var(--color-background); border: 1px solid var(--color-control-border); border-radius: var(--radius-sm); padding: 7px 9px; min-width: 0; }
.tk textarea { width: 100%; resize: vertical; }
.tk-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--color-primary); color: var(--color-button-text) !important; border: 1px solid var(--color-primary); border-radius: var(--radius-sm); padding: 8px 14px; font-weight: 600; cursor: pointer; text-decoration: none; font-size: .875rem; }
.tk-btn:hover { background: #67E8F9; border-color: #67E8F9; }
.tk-btn--ghost { background: transparent; color: var(--color-heading) !important; border-color: var(--color-control-border); }
.tk-btn--ghost:hover { background: var(--color-surface-hover); border-color: var(--color-muted); }
.tk-file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tk-tablewrap { overflow-x: auto; }
.tk-table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: .84rem; }
.tk-table th { text-align: left; font: 500 .7rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--color-muted); padding: 8px 10px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.tk-table th button { all: unset; cursor: pointer; }
.tk-table th button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.tk-table td { padding: 8px 10px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.tk-table td select { padding: 4px 6px; }
.tk-table--tight { min-width: 0; }
.tk-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.tk-form label { display: flex; flex-direction: column; gap: 3px; font-size: .75rem; color: var(--color-muted); min-width: 0; }
.tk-form .tk-wide { grid-column: 1 / -1; }
.tk-form .tk-half { grid-column: span 2; }
.tk-form fieldset { grid-column: 1 / -1; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 12px; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tk-form legend { font-size: .75rem; color: var(--color-muted); padding: 0 6px; }
.tk-msg { font-size: .8125rem; color: var(--color-muted); }
.tk-msg--err { color: var(--tk-crit); }
.tk-code { font: .78rem var(--font-mono); background: var(--color-background); border: 1px solid var(--color-border); border-radius: 6px; padding: 2px 6px; overflow-wrap: anywhere; }
.tk-big { font: 800 clamp(2.5rem, 8vw, 4rem)/1 var(--font-heading); color: var(--color-heading); }
.tk-verdict { border-left: 4px solid var(--color-border); }
.tk-verdict--good { border-left-color: var(--tk-good); }
.tk-verdict--bad { border-left-color: var(--tk-crit); }
.tk-verdict--wait { border-left-color: var(--tk-warn); }
.tk-steps { display: flex; flex-wrap: wrap; gap: var(--s1); list-style: none; padding: 0; margin: 0; counter-reset: tkstep; }
.tk-steps li { counter-increment: tkstep; font-size: .8125rem; color: var(--color-muted); display: flex; align-items: center; gap: 6px; }
.tk-steps li::before { content: counter(tkstep); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--color-surface-hover); color: var(--color-heading); font: 600 .75rem var(--font-mono); }
.tk-steps li + li::after { content: ""; order: -1; width: 18px; height: 1px; background: var(--color-border); }
.tk-chiprow { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-chip { font: 500 .75rem var(--font-mono); border: 1px solid var(--color-border); background: var(--color-background); padding: 3px 8px; border-radius: 6px; color: var(--color-text); cursor: pointer; }
.tk-chip:hover { border-color: var(--color-primary); }
.tk-chip[aria-pressed="true"] { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-button-text); }
.tk-chip--static { cursor: default; }
.tk-chip--static:hover { border-color: var(--color-border); }
.tk-credit { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: .8125rem; color: var(--color-muted); border-top: 1px solid var(--color-border); padding-top: var(--s2); }
.tk-credit b { color: var(--color-text); font-weight: 600; }
.tk-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tk-card > .tk-actions { margin-top: var(--s2); }
.tk-card > .tk-msg { margin-top: 12px; }
.tk-table td:last-child { white-space: nowrap; }

@media (max-width: 860px) {
  .tk-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-grid2 { grid-template-columns: minmax(0, 1fr); }
  .tk-detail { grid-template-columns: minmax(0, 1fr); }
  .tk-form, .tk-form fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 440px) {
  .tk-card { padding: var(--s2); }
  .tk-tabs a { padding: 7px 11px; font-size: .8125rem; }
  .tk-ax--y { min-width: 0; font-size: 0; }
  .tk-ax--y b { font-size: .75rem; }
  .tk-kpi__val { font-size: 1.75rem; }
  .tk-bar { grid-template-columns: 96px minmax(0, 1fr) 22px; }
  .tk-risk__side { padding-right: 10px; }
}
@media (prefers-reduced-motion: no-preference) { .tk-prog i, .tk-bar__track i { transition: width .3s; } }

/* Printing gives a light, board-pack friendly page. */
@media print {
  :root { --color-background: #fff; --color-surface: #fff; --color-surface-hover: #eef1f4; --color-primary: #0f5c73;
          --color-heading: #111; --color-text: #222; --color-muted: #555; --color-border: #c9d0d6; --color-button-text: #fff; }
  .tk { --tk-good: #0ca30c; --tk-warn: #e0a100; --tk-serious: #e0733f; --tk-crit: #d03b3b; }
  body { background: #fff; }
  .nav, .foot, .skip, .tk-noprint, #tk-tip { display: none !important; }
  .page-head { padding: 0 0 12px; }
  .tk-card, .tk-kpi, .tk-risk, .tk-dec { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.tk-view { display: flex; flex-direction: column; gap: var(--s3); }
.tk-scroll { max-height: 320px; overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.tk-scroll .tk-table th { position: sticky; top: 0; background: var(--color-surface); }
.tk h3.tk-sub { font: 500 .7rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; margin: var(--s2) 0 var(--s1); }
.tk-card > .tk-form, .tk-card > .tk-grid2, .tk-card > .tk-tags { margin-top: var(--s2); }
.tk-big + p { margin: 6px 0 12px; max-width: 46ch; }
.tk-bar--on .tk-bar__track i { background: var(--color-primary); }
.tk-bar--bad .tk-bar__track i { background: var(--tk-crit); }
.tk-issue { font-size: .8125rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
@media print { .tk-scroll { max-height: none; overflow: visible; } }
.tk-st-proof { background: var(--color-control-border); }
.tk-st-unmapped { background: var(--color-surface-hover); outline: 1px solid var(--color-border); outline-offset: -1px; }
.tk-stackbar { display: flex; gap: 2px; height: 12px; margin: 8px 0 6px; }
.tk-stackbar i { display: block; height: 100%; width: 0; min-width: 3px; border-radius: 2px; }
button.tk-kpi { text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.tk-kpi:hover { background: var(--color-surface-hover); }
button.tk-kpi[aria-pressed="true"] { border-color: var(--color-primary); }
.tk-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s2); }
.tk-cols h3 { font-size: .8125rem; margin-bottom: 6px; }
.tk-chip--partial { border-style: dashed; color: var(--color-muted); }
.tk-rowbtn { all: unset; cursor: pointer; display: block; }
.tk-rowbtn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.tk-rowbtn b { color: var(--color-heading); font-weight: 600; }
tr.tk-open td { background: var(--color-background); }
@media (max-width: 860px) { .tk-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px) { .tk-cols { grid-template-columns: minmax(0, 1fr); } }
.tk-bars--wide .tk-bar { grid-template-columns: 136px minmax(0, 1fr) 52px; }
.tk-bars--wide { margin-top: 12px; }
.tk-grid2--top { align-items: start; }
.tk-grid2--top .tk-form { align-items: start; }
