/*
  A2K design system: base and components
  Imports nothing. Load tokens.css first (then brands/<client>.css if any), then this file.
  Every colour, size, radius, shadow and timing comes from tokens.css through var().
  The few component constants that tokens.css does not hold are named once in the block below.

  Contents
    0  Component constants
    1  Base
    2  Type helpers
    3  Layout: page, app shell, header, page header
    4  Navigation: nav rows, tabs, segmented, breadcrumbs, pagination
    5  Buttons
    6  Forms
    7  Surfaces: card, stat, total, callout, empty state, skeleton
    8  Data: table, status, progress, chart frame, bars, avatar, keycap
    9  Overlays: dialog, menu, popover, toast, tooltip
   10  Product frame (a cropped screen in code)
   11  Utilities and motion
*/

/* ---------- 0. Component constants ---------- */
:root {
  --ring: 3px;                /* focus ring width */
  --dot: 6px;                 /* status dot */
  --scrim: rgb(20 32 26 / 0.4);
  --dialog-w: 480px;
  --popover-w: 240px;
  --toast-w: 360px;
  --tooltip-max: 240px;
  --avatar-sm: 24px;
  --avatar-md: 32px;
  --avatar-lg: 40px;
  --switch-w: 36px;
  --switch-h: 20px;
  --switch-knob: 14px;
  --check: 16px;
  --progress-h: 6px;
  --chart-h: 300px;
  --axis-w: 44px;
  --stagger: 50ms;
  --textarea-min: 96px;
}

/* ---------- 1. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: var(--weight-regular);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.a2k-app { font-size: var(--text-md); line-height: var(--leading-md); }
.a2k-page { font-size: var(--text-base); line-height: var(--leading-base); }

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

::selection { background: var(--selection); color: var(--text); }

:focus-visible {
  outline: var(--ring) solid var(--focus-ring);
  outline-offset: var(--space-0-5);
}

.is-focus { outline: var(--ring) solid var(--focus-ring); outline-offset: var(--space-0-5); }

.a2k-skip {
  position: absolute; left: var(--space-4); top: var(--space-4); z-index: var(--z-toast);
  transform: translateY(-200%);
  padding: var(--space-2) var(--space-4);
  background: var(--accent); color: var(--on-accent);
  border-radius: var(--radius-md);
  text-decoration: none;
}
.a2k-skip:focus { transform: none; }

.a2k-link {
  color: var(--text);
  text-decoration-line: underline;
  text-decoration-color: var(--line-strong);
  transition: text-decoration-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.a2k-link:hover { text-decoration-color: var(--accent); }

/* ---------- 2. Type helpers ---------- */
.a2k-hero {
  font-size: var(--text-5xl); line-height: var(--leading-5xl);
  font-weight: var(--weight-medium); letter-spacing: var(--tracking-hero);
  text-wrap: balance;
}
.a2k-headline {
  font-size: var(--text-4xl); line-height: var(--leading-4xl);
  font-weight: var(--weight-medium); letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
.a2k-page-title {
  font-size: var(--text-2xl); line-height: var(--leading-2xl);
  font-weight: var(--weight-medium);
}
.a2k-title {
  font-size: var(--text-xl); line-height: var(--leading-xl);
  font-weight: var(--weight-medium);
}
.a2k-lead {
  font-size: var(--text-lg); line-height: var(--leading-lg);
  color: var(--text-2);
  max-width: var(--prose-max);
}
.a2k-body { font-size: var(--text-base); line-height: var(--leading-base); }
.a2k-small { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs); line-height: var(--leading-xs);
  letter-spacing: var(--tracking-meta);
  color: var(--text-3);
}
.a2k-prose { max-width: var(--prose-max); }
.a2k-prose > * + * { margin-top: var(--space-4); }
.a2k-money { color: var(--money); }
.a2k-muted { color: var(--text-2); }
.a2k-faint { color: var(--text-3); }

@media (max-width: 639px) {
  .a2k-hero { font-size: var(--text-4xl); line-height: var(--leading-4xl); letter-spacing: var(--tracking-display); }
  .a2k-headline { font-size: var(--text-3xl); line-height: var(--leading-3xl); }
}

/* Logo: the name as text, "AI" in sage. No dot, no tile. */
.a2k-logo {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-xl); line-height: var(--leading-xl);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-normal);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.a2k-logo span { color: var(--brand-mark); }

/* Icons: one set, one stroke. Drawn on Lucide's 24px grid, sized here. */
.a2k-icon { width: var(--icon-sm); height: var(--icon-sm); flex: none; }
.a2k-icon--md { width: var(--icon-md); height: var(--icon-md); }
.a2k-icon--lg { width: var(--icon-lg); height: var(--icon-lg); }

/* ---------- 3. Layout ---------- */
.a2k-wrap {
  width: 100%; max-width: var(--page-max);
  margin-inline: auto; padding-inline: var(--page-pad);
}
.a2k-wrap--wide { max-width: var(--content-max); }
.a2k-section { padding-block: var(--space-24); }
.a2k-section--tight { padding-block: var(--space-16); }

@media (max-width: 639px) {
  :root { --page-pad: 16px; }
  .a2k-section { padding-block: var(--space-16); }
  .a2k-section--tight { padding-block: var(--space-12); }
}

/* App shell: sidebar 256, header 56, content capped at 1440. */
.a2k-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.a2k-sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 0 var(--space-4) var(--space-4);
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: var(--z-nav);
}
.a2k-sidebar__top {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); flex: none;
  padding-inline: var(--space-3);
}
.a2k-sidebar__nav { display: flex; flex-direction: column; gap: var(--space-0-5); padding-top: var(--space-4); }
.a2k-sidebar__foot { margin-top: auto; padding-top: var(--space-4); }
.a2k-btn.a2k-menu-btn { display: none; }

.a2k-main { min-width: 0; display: flex; flex-direction: column; }
.a2k-header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  height: var(--header-h); flex: none;
  padding-inline: var(--page-pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.a2k-header__group { display: flex; align-items: center; gap: var(--space-2); }
.a2k-content {
  width: 100%; max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--space-8) var(--page-pad) var(--space-16);
}
.a2k-stack > * + * { margin-top: var(--space-6); }
.a2k-stack--lg > * + * { margin-top: var(--space-12); }

@media (max-width: 959px) {
  .a2k-shell { grid-template-columns: minmax(0, 1fr); }
  .a2k-sidebar {
    height: auto; max-height: 100vh;
    padding: 0 var(--page-pad);
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .a2k-sidebar__top { padding-inline: 0; }
  .a2k-sidebar__nav, .a2k-sidebar__foot { display: none; }
  .a2k-sidebar.is-open .a2k-sidebar__nav { display: flex; padding-top: 0; padding-bottom: var(--space-4); }
  .a2k-sidebar.is-open .a2k-sidebar__foot { display: block; padding-bottom: var(--space-4); }
  .a2k-btn.a2k-menu-btn { display: inline-flex; }
  .a2k-header { position: static; }
}

/* Page header: names the context, never a greeting. */
.a2k-page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.a2k-page-header__text { display: grid; gap: var(--space-1); min-width: 0; }
.a2k-page-header__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- 4. Navigation ---------- */
.a2k-nav__label {
  padding-inline: var(--space-3);
  margin-top: var(--space-6); margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs); line-height: var(--leading-xs);
  letter-spacing: var(--tracking-meta);
  color: var(--text-3);
}
.a2k-nav__label:first-child { margin-top: 0; }
.a2k-nav__item {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--control-md);
  padding-inline: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-2);
  text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.a2k-nav__item .a2k-icon { color: var(--text-3); transition: color var(--dur-fast) var(--ease); }
.a2k-nav__item:hover, .a2k-nav__item.is-hover { background: var(--surface-hover); color: var(--text); }
.a2k-nav__item:hover .a2k-icon, .a2k-nav__item.is-hover .a2k-icon { color: var(--text-2); }
.a2k-nav__item:active { background: var(--surface-active); transform: scale(var(--press-scale)); }
.a2k-nav__item[aria-current="page"] { background: var(--surface-raised); color: var(--text); }
.a2k-nav__item[aria-current="page"] .a2k-icon { color: var(--text); }
.a2k-nav__item[aria-disabled="true"] { color: var(--text-disabled); pointer-events: none; }
.a2k-nav__count {
  margin-left: auto;
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-meta);
  color: var(--text-3);
}

/* Breadcrumbs */
.a2k-crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.a2k-crumbs li { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-3); }
.a2k-crumbs li + li::before { content: "/"; color: var(--text-3); }
.a2k-crumbs a { color: var(--text-2); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
.a2k-crumbs a:hover { color: var(--text); text-decoration: underline; }
.a2k-crumbs [aria-current="page"] { color: var(--text); }

/* Tabs: text with a 2px green underline on the active one. */
.a2k-tabs {
  display: flex; gap: var(--space-6);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.a2k-tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--control-lg);
  margin-bottom: calc(-1 * var(--space-px));
  padding: 0;
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: var(--text-md); line-height: var(--leading-md); font-weight: var(--weight-medium);
  white-space: nowrap; text-decoration: none;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.a2k-tab:hover, .a2k-tab.is-hover { color: var(--text); border-bottom-color: var(--line-strong); }
.a2k-tab[aria-selected="true"], .a2k-tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.a2k-tab:disabled, .a2k-tab[aria-disabled="true"] { color: var(--text-disabled); border-bottom-color: transparent; cursor: not-allowed; }
.a2k-tab__count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-3); }

/* Segmented control: sunken track, raised selected segment. */
.a2k-segmented {
  display: inline-flex; gap: var(--space-0-5);
  padding: var(--space-0-5);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
}
.a2k-segmented__item {
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--control-sm);
  padding-inline: var(--space-3);
  background: transparent; border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.a2k-segmented__item:hover, .a2k-segmented__item.is-hover { color: var(--text); background: var(--surface-hover); }
.a2k-segmented__item:active { transform: scale(var(--press-scale)); }
.a2k-segmented__item[aria-pressed="true"], .a2k-segmented__item[aria-selected="true"] {
  background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-1);
}
.a2k-segmented__item:disabled { color: var(--text-disabled); cursor: not-allowed; background: transparent; }

/* Pagination */
.a2k-pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.a2k-pagination__list { display: flex; align-items: center; gap: var(--space-1); }
.a2k-pagination__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--control-md); height: var(--control-md);
  padding-inline: var(--space-2);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--text-md); text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.a2k-pagination__btn:hover, .a2k-pagination__btn.is-hover { background: var(--surface-hover); color: var(--text); }
.a2k-pagination__btn:active { transform: scale(var(--press-scale)); background: var(--surface-active); }
.a2k-pagination__btn[aria-current="page"] { background: var(--surface-raised); border-color: var(--line-strong); color: var(--text); }
.a2k-pagination__btn:disabled, .a2k-pagination__btn[aria-disabled="true"] { color: var(--text-disabled); cursor: not-allowed; pointer-events: none; }

@media (max-width: 639px) {
  .a2k-nav__item, .a2k-pagination__btn { height: var(--control-lg); min-width: var(--control-lg); }
  .a2k-tab { height: var(--control-lg); }
  .a2k-segmented__item { height: var(--control-lg); }
}

/* ---------- 5. Buttons ---------- */
.a2k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent; color: var(--text);
  font-size: var(--text-md); line-height: var(--leading-md); font-weight: var(--weight-medium);
  text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.a2k-btn:active, .a2k-btn.is-active { transform: scale(var(--press-scale)); }
.a2k-btn--sm { height: var(--control-sm); padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.a2k-btn--lg { height: var(--control-lg); padding: 0 var(--space-5); }
.a2k-btn--block { width: 100%; }

.a2k-btn--primary { background: var(--accent); color: var(--on-accent); }
.a2k-btn--primary:hover, .a2k-btn--primary.is-hover { background: var(--accent-hover); }
.a2k-btn--primary:active, .a2k-btn--primary.is-active { background: var(--accent-press); }

.a2k-btn--secondary { background: var(--surface-raised); color: var(--text); border-color: var(--line-strong); }
.a2k-btn--secondary:hover, .a2k-btn--secondary.is-hover { border-color: var(--text-3); background: var(--surface-raised); }
.a2k-btn--secondary:active, .a2k-btn--secondary.is-active { background: var(--surface-sunken); }

.a2k-btn--ghost { background: transparent; color: var(--text-2); }
.a2k-btn--ghost:hover, .a2k-btn--ghost.is-hover { background: var(--surface-hover); color: var(--text); }
.a2k-btn--ghost:active, .a2k-btn--ghost.is-active { background: var(--surface-active); }

.a2k-btn--danger { background: var(--negative-soft); color: var(--negative); }
.a2k-btn--danger:hover, .a2k-btn--danger.is-hover { border-color: var(--negative); }
.a2k-btn--danger:active, .a2k-btn--danger.is-active { background: var(--negative-soft); border-color: var(--negative); }
/* Solid red only in the final confirm of a destructive dialog. */
.a2k-btn--danger-solid { background: var(--negative); color: var(--on-accent); }
.a2k-btn--danger-solid:hover { opacity: 0.9; }

.a2k-btn--icon { width: var(--control-md); padding: 0; }
.a2k-btn--icon.a2k-btn--sm { width: var(--control-sm); }
.a2k-btn--icon.a2k-btn--lg { width: var(--control-lg); }

.a2k-btn:disabled, .a2k-btn[aria-disabled="true"] {
  background: var(--surface-sunken); color: var(--text-disabled);
  border-color: transparent; cursor: not-allowed; transform: none;
}
.a2k-btn--ghost:disabled { background: transparent; }

.a2k-btn.is-loading { pointer-events: none; }
.a2k-btn.is-loading::before {
  content: ""; flex: none;
  width: var(--icon-sm); height: var(--icon-sm);
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: var(--radius-pill);
  animation: a2k-spin 800ms linear infinite;
}
@keyframes a2k-spin { to { transform: rotate(360deg); } }

@media (max-width: 639px) {
  .a2k-btn { height: var(--control-lg); }
  .a2k-btn--icon { width: var(--control-lg); }
}

/* ---------- 6. Forms ---------- */
.a2k-field { display: grid; gap: var(--space-2); min-width: 0; }
.a2k-label { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium); color: var(--text-2); }
.a2k-help { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-3); }
.a2k-error { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--negative); display: flex; align-items: center; gap: var(--space-1); }

.a2k-input, .a2k-textarea, .a2k-select select {
  width: 100%;
  height: var(--control-md);
  padding: 0 var(--space-3);
  background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-md); line-height: var(--leading-md);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.a2k-textarea { height: auto; min-height: var(--textarea-min); padding: var(--space-2) var(--space-3); resize: vertical; }
.a2k-input::placeholder, .a2k-textarea::placeholder { color: var(--text-3); }
.a2k-input:hover, .a2k-textarea:hover, .a2k-select select:hover,
.a2k-input.is-hover, .a2k-textarea.is-hover, .a2k-select select.is-hover { border-color: var(--text-3); }
.a2k-input:focus-visible, .a2k-textarea:focus-visible, .a2k-select select:focus-visible,
.a2k-input.is-focus, .a2k-textarea.is-focus, .a2k-select select.is-focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 var(--ring) var(--focus-ring);
}
.a2k-input[aria-invalid="true"], .a2k-textarea[aria-invalid="true"], .a2k-select select[aria-invalid="true"] { border-color: var(--negative); }
.a2k-input:disabled, .a2k-textarea:disabled, .a2k-select select:disabled {
  background: var(--surface-sunken); color: var(--text-disabled); border-color: var(--line); cursor: not-allowed;
}
.a2k-input:read-only:not(:disabled) { background: var(--surface-sunken); }

.a2k-select { position: relative; }
.a2k-select select { appearance: none; -webkit-appearance: none; padding-right: var(--space-8); cursor: pointer; }
.a2k-select .a2k-icon { position: absolute; right: var(--space-3); top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }

.a2k-input-group { position: relative; display: flex; align-items: center; }
.a2k-input-group .a2k-input { padding-left: var(--space-8); }
.a2k-input-group > .a2k-icon { position: absolute; left: var(--space-3); color: var(--text-3); pointer-events: none; }
.a2k-input-group--action { gap: var(--space-2); }
.a2k-input-group--action .a2k-input { padding-left: var(--space-3); flex: 1 1 auto; min-width: 0; }

/* Checkbox, radio, switch: the input itself is drawn, so it keeps native keyboard and form behaviour. */
.a2k-check, .a2k-switch-row {
  display: flex; align-items: flex-start; gap: var(--space-3);
  font-size: var(--text-md); line-height: var(--leading-md); color: var(--text);
  cursor: pointer;
}
.a2k-check__text { display: grid; gap: var(--space-0-5); }
.a2k-check input[type="checkbox"], .a2k-check input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  flex: none; position: relative;
  width: var(--check); height: var(--check);
  margin: var(--space-0-5) 0 0;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.a2k-check input[type="radio"] { border-radius: var(--radius-pill); }
.a2k-check input:hover, .a2k-check input.is-hover { border-color: var(--text-3); }
.a2k-check input:focus-visible { outline: var(--ring) solid var(--focus-ring); outline-offset: var(--space-0-5); }
.a2k-check input[type="checkbox"]:checked, .a2k-check input[type="checkbox"]:indeterminate { background: var(--accent); border-color: var(--accent); }
.a2k-check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid var(--on-accent); border-width: 0 2px 2px 0;
  rotate: 45deg;
}
.a2k-check input[type="checkbox"]:indeterminate::after {
  content: ""; position: absolute; left: 3px; top: 6px;
  width: 8px; height: 2px; background: var(--on-accent);
}
.a2k-check input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--surface-raised); }
.a2k-check input[aria-invalid="true"] { border-color: var(--negative); }
.a2k-check input:disabled { background: var(--surface-sunken); border-color: var(--line); cursor: not-allowed; }
.a2k-check input:disabled:checked { background: var(--text-disabled); border-color: var(--text-disabled); }
.a2k-check:has(input:disabled) { color: var(--text-disabled); cursor: not-allowed; }

.a2k-switch-row { align-items: center; justify-content: space-between; }
.a2k-switch {
  appearance: none; -webkit-appearance: none;
  flex: none; position: relative;
  width: var(--switch-w); height: var(--switch-h);
  margin: 0;
  background: var(--surface-sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.a2k-switch::after {
  content: ""; position: absolute; top: 50%; left: var(--space-0-5);
  width: var(--switch-knob); height: var(--switch-knob);
  translate: 0 -50%;
  background: var(--text-3);
  border-radius: var(--radius-pill);
  transition: translate var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.a2k-switch:hover { border-color: var(--text-3); }
.a2k-switch:checked { background: var(--accent); border-color: var(--accent); }
.a2k-switch:checked::after { translate: calc(var(--switch-w) - var(--switch-knob) - var(--space-1) - 2px) -50%; background: var(--on-accent); }
.a2k-switch:disabled { background: var(--surface-sunken); border-color: var(--line); cursor: not-allowed; }
.a2k-switch:disabled::after { background: var(--text-disabled); }

.a2k-form { display: grid; gap: var(--space-5); }
.a2k-form__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 639px) {
  .a2k-input, .a2k-select select { height: var(--control-lg); }
  .a2k-form__row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 7. Surfaces ---------- */
.a2k-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  min-width: 0;
}
.a2k-card--compact { padding: var(--space-5); }
.a2k-card--flush { padding: 0; overflow: hidden; }
.a2k-card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.a2k-card--flush > .a2k-card__head { padding: var(--space-5) var(--space-6) 0; margin-bottom: var(--space-4); }
.a2k-card--flush { display: flex; flex-direction: column; }
.a2k-card__foot { margin-top: auto; border-top: 1px solid var(--line); padding: var(--space-2) var(--space-3); }
.a2k-card--flush > .a2k-table-wrap { flex: 1 1 auto; display: flex; flex-direction: column; }
.a2k-card--flush > .a2k-table-wrap > .a2k-table { flex: 1 1 auto; }
.a2k-card--flush .a2k-table th:first-child, .a2k-card--flush .a2k-table td:first-child { padding-left: var(--space-6); }
.a2k-card--flush .a2k-table th:last-child, .a2k-card--flush .a2k-table td:last-child { padding-right: var(--space-6); }
.a2k-card__title { font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-medium); }
.a2k-card__sub { margin-top: var(--space-1); }

/* Stat: label, figure, change against a named period. */
.a2k-stat {
  display: flex; flex-direction: column; gap: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  min-width: 0;
}
.a2k-stat__label { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-stat__figure {
  font-size: var(--text-3xl); line-height: var(--leading-3xl);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.a2k-stat__change { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-stat__delta { font-weight: var(--weight-medium); }
.a2k-stat__delta--up { color: var(--positive); }
.a2k-stat__delta--down { color: var(--negative); }
.a2k-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.a2k-stats--lead { grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(0, 1fr)); }
@media (max-width: 1279px) { .a2k-stats, .a2k-stats--lead { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) {
  .a2k-stats, .a2k-stats--lead { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .a2k-stat { padding: var(--space-4); }
  .a2k-card--flush > .a2k-card__head { padding-inline: var(--space-4); }
}

/* The total: a key figure with a ledger double rule beneath it. Once per screen. */
.a2k-total { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.a2k-total__label { font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-total__figure {
  position: relative;
  padding-bottom: var(--space-3);
  font-size: var(--text-3xl); line-height: var(--leading-3xl);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.a2k-total__figure::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--space-1);
  border-top: 1px solid var(--text); border-bottom: 1px solid var(--text);
}
.a2k-total__note { margin-top: var(--space-1); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-total--lg .a2k-total__figure { font-size: var(--text-4xl); line-height: var(--leading-4xl); letter-spacing: var(--tracking-display); }

/* Callout */
.a2k-callout {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-md); line-height: var(--leading-md);
}
.a2k-callout .a2k-icon { margin-top: var(--space-0-5); color: var(--text-2); }
.a2k-callout__title { font-weight: var(--weight-medium); }
.a2k-callout__text { margin-top: var(--space-1); color: var(--text-2); }
.a2k-callout--info { background: var(--accent-soft); }
.a2k-callout--info .a2k-icon { color: var(--accent); }
.a2k-callout--positive { background: var(--positive-soft); }
.a2k-callout--positive .a2k-icon { color: var(--positive); }
.a2k-callout--warning { background: var(--warning-soft); }
.a2k-callout--warning .a2k-icon { color: var(--warning); }
.a2k-callout--negative { background: var(--negative-soft); }
.a2k-callout--negative .a2k-icon { color: var(--negative); }

/* Empty state: says what will appear and the one action that makes it appear. */
.a2k-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}
.a2k-empty__title { font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-medium); }
.a2k-empty__text { max-width: 44ch; color: var(--text-2); }
.a2k-empty .a2k-btn { margin-top: var(--space-2); }

/* Skeleton: a static tone, no shimmer. */
.a2k-skeleton { display: block; height: var(--space-4); background: var(--surface-sunken); border-radius: var(--radius-sm); }
.a2k-skeleton--title { height: var(--space-6); width: 40%; }
.a2k-skeleton--block { height: var(--space-24); border-radius: var(--radius-md); }
.a2k-skeleton--circle { width: var(--avatar-lg); height: var(--avatar-lg); border-radius: var(--radius-pill); }
.a2k-skeleton--short { width: 60%; }

/* ---------- 8. Data ---------- */
/* Table: sunken header in mono, 44px rows, numbers right aligned. */
.a2k-table-wrap { min-width: 0; overflow-x: auto; }
.a2k-table { width: 100%; border-collapse: collapse; font-size: var(--text-md); line-height: var(--leading-md); }
.a2k-table caption { text-align: left; padding-bottom: var(--space-3); }
.a2k-table th {
  height: var(--row-compact);
  padding: 0 var(--space-4);
  background: var(--surface-sunken);
  font-family: var(--font-mono); font-weight: var(--weight-regular);
  font-size: var(--text-xs); line-height: var(--leading-xs); letter-spacing: var(--tracking-meta);
  color: var(--text-3);
  text-align: left; white-space: nowrap;
}
.a2k-table td {
  height: var(--row);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  transition: background-color var(--dur-fast) var(--ease);
}
.a2k-table tbody tr:last-child td { border-bottom: 0; }
.a2k-table tbody tr:hover td, .a2k-table tbody tr.is-hover td { background: var(--surface-hover); }
.a2k-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.a2k-table td:first-child { font-weight: var(--weight-medium); }
.a2k-table--compact td { height: var(--row-compact); }
.a2k-table .a2k-meta { white-space: nowrap; }

/* Phone: each row becomes a compact two-line list row. First cell is the title, other cells sit under it,
   the last numeric cell is right aligned on the same row. A hairline between rows, about 56px each. */
@media (max-width: 639px) {
  .a2k-table, .a2k-table tbody { display: block; width: 100%; }
  .a2k-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .a2k-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-4); align-items: center;
    min-height: 56px; padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--line);
  }
  .a2k-table tbody tr:last-child { border-bottom: 0; }
  .a2k-table td { display: block; grid-column: 1; height: auto; padding: 0; border: 0; text-align: left; }
  .a2k-table td:first-child { font-weight: var(--weight-medium); }
  .a2k-table td.is-num::before {
    content: attr(data-label) " ";
    font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-meta); color: var(--text-3);
    margin-right: var(--space-2);
  }
  .a2k-table td.is-num:last-child { grid-column: 2; grid-row: 1 / span 4; align-self: center; text-align: right; }
  .a2k-table td.is-num:last-child::before { display: block; margin: 0; }
  .a2k-table tbody tr:hover td { background: transparent; }
  .a2k-table-wrap { overflow: visible; }

  /* Pairs variant: the name is the row title, every other cell is an aligned label and value pair. */
  .a2k-table.a2k-table--pairs tr { display: block; padding: var(--space-3) var(--space-4) var(--space-4); }
  .a2k-table.a2k-table--pairs td { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); min-height: var(--space-8); text-align: right; }
  .a2k-table.a2k-table--pairs td::before {
    content: attr(data-label); display: block; margin: 0;
    font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-meta); color: var(--text-3); text-align: left;
  }
  .a2k-table.a2k-table--pairs td:first-child { display: block; min-height: var(--control-md); text-align: left; padding-bottom: var(--space-1); margin-bottom: var(--space-1); border-bottom: 1px solid var(--line); }
  .a2k-table.a2k-table--pairs td:first-child::before { display: none; }
  .a2k-table.a2k-table--pairs td.is-num:last-child { grid-column: auto; grid-row: auto; align-self: auto; text-align: right; }
}

/* Status: a 6px dot and a word, or a soft pill for tables. */
.a2k-status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); white-space: nowrap; }
.a2k-dot { flex: none; width: var(--dot); height: var(--dot); border-radius: var(--radius-pill); background: var(--text-3); }
.a2k-dot--positive { background: var(--positive); }
.a2k-dot--negative { background: var(--negative); }
.a2k-dot--warning { background: var(--warning); }
.a2k-dot--neutral { background: var(--text-3); }

.a2k-pill {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken); color: var(--text-2);
  font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-medium);
  white-space: nowrap;
}
.a2k-pill::before { content: ""; width: var(--dot); height: var(--dot); border-radius: var(--radius-pill); background: currentColor; }
.a2k-pill--positive { background: var(--positive-soft); color: var(--positive); }
.a2k-pill--negative { background: var(--negative-soft); color: var(--negative); }
.a2k-pill--warning { background: var(--warning-soft); color: var(--warning); }

/* Progress bar */
.a2k-progress { display: grid; gap: var(--space-2); }
.a2k-progress__head { display: flex; align-items: baseline; justify-content: space-between; font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-progress__track { height: var(--progress-h); background: var(--surface-sunken); border-radius: var(--radius-xs); overflow: hidden; }
.a2k-progress__bar { width: var(--value, 0%); height: 100%; background: var(--accent); border-radius: var(--radius-xs); }

/* Avatar */
.a2k-avatar {
  display: inline-grid; place-items: center; flex: none;
  width: var(--avatar-md); height: var(--avatar-md);
  border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: var(--text-xs); line-height: var(--leading-xs); font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-meta);
}
.a2k-avatar--sm { width: var(--avatar-sm); height: var(--avatar-sm); }
.a2k-avatar--lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: var(--text-sm); }

/* Keycap */
.a2k-kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--icon-lg); height: var(--icon-lg);
  padding: 0 var(--space-1);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--leading-xs);
  color: var(--text-2);
}

/* Chart frame: a title that states the finding, a legend, a muted grid. Text is real HTML so it never scales below 12px. */
.a2k-chart {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  min-width: 0;
}
.a2k-chart__head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-6); }
.a2k-chart__title { font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-medium); }
.a2k-chart__sub { margin-top: var(--space-1); }
.a2k-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--text-2); }
.a2k-legend li { display: inline-flex; align-items: center; gap: var(--space-2); }
.a2k-legend li::before { content: ""; width: var(--space-4); height: var(--space-0-5); background: var(--swatch, var(--chart-lead)); }
.a2k-chart__plot { display: grid; grid-template-columns: var(--axis-w) minmax(0, 1fr); column-gap: var(--space-3); height: var(--chart-h); }
.a2k-chart__y { position: relative; }
.a2k-chart__y span, .a2k-chart__x span {
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--leading-xs); letter-spacing: var(--tracking-meta);
  color: var(--chart-label);
}
.a2k-chart__y span { position: absolute; right: 0; top: var(--at); translate: 0 -50%; }
.a2k-chart__area { position: relative; }
.a2k-chart__area svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.a2k-chart__grid { stroke: var(--chart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; fill: none; }
.a2k-chart__line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.a2k-chart__line--lead { stroke: var(--chart-lead); }
.a2k-chart__line--prev { stroke: var(--chart-muted-2); stroke-dasharray: 2 5; }
.a2k-chart__point {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--space-2); height: var(--space-2);
  translate: -50% -50%;
  background: var(--chart-lead);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 2px var(--surface);
}
.a2k-chart__tag {
  position: absolute; right: 0; top: var(--y);
  translate: 0 calc(-100% - var(--space-4));
  padding: var(--space-1) var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--leading-xs); letter-spacing: var(--tracking-meta);
  color: var(--text);
  white-space: nowrap;
}
.a2k-chart__x { display: grid; grid-template-columns: var(--axis-w) minmax(0, 1fr); column-gap: var(--space-3); margin-top: var(--space-3); }
.a2k-chart__x div { position: relative; height: var(--leading-xs); }
.a2k-chart__x span { position: absolute; left: var(--at); top: 0; translate: -50% 0; white-space: nowrap; }
.a2k-chart__x span:last-child { translate: -100% 0; }

/* Column bars: one highlighted, the rest neutral. */
.a2k-bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-4); height: var(--chart-h); padding-top: var(--space-8); position: relative; }
.a2k-bars__col { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: var(--space-3); position: relative; z-index: 1; }
.a2k-bars__track { position: relative; border-bottom: 1px solid var(--line-strong); }
.a2k-bars__bar { position: absolute; left: 0; right: 0; bottom: 0; height: var(--h); background: var(--chart-muted); border-radius: var(--radius-xs) var(--radius-xs) 0 0; }
.a2k-bars__bar.is-lead { background: var(--chart-lead); }
.a2k-bars__value {
  position: absolute; left: 0; right: 0; bottom: calc(var(--h) + var(--space-2));
  text-align: center;
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--leading-xs); letter-spacing: var(--tracking-meta);
  color: var(--text-2);
}
.a2k-bars__value.is-lead { color: var(--text); font-weight: var(--weight-medium); }
.a2k-bars__label { text-align: center; font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--leading-xs); letter-spacing: var(--tracking-meta); color: var(--chart-label); }

@media (max-width: 639px) {
  :root { --chart-h: 220px; --axis-w: 36px; }
  .a2k-chart { padding: var(--space-4); }
  .a2k-bars { gap: var(--space-2); }
  .a2k-hide-sm { display: none !important; }
}

/* ---------- 9. Overlays ---------- */
.a2k-dialog {
  width: min(var(--dialog-w), calc(100% - var(--space-8)));
  padding: 0;
  background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
}
dialog.a2k-dialog::backdrop { background: var(--scrim); }
dialog.a2k-dialog[open] { animation: a2k-rise var(--dur-slow) var(--ease) both; }
.a2k-dialog__head { padding: var(--space-6) var(--space-6) var(--space-2); }
.a2k-dialog__title { font-size: var(--text-xl); line-height: var(--leading-xl); font-weight: var(--weight-medium); }
.a2k-dialog__body { padding: var(--space-2) var(--space-6) var(--space-6); color: var(--text-2); }
.a2k-dialog__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--line); }

.a2k-anchor { position: relative; display: inline-block; }
.a2k-menu, .a2k-popover {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  z-index: var(--z-popover);
}
.a2k-menu { min-width: var(--popover-w); padding: var(--space-1); }
.a2k-menu--float, .a2k-popover--float { position: absolute; top: calc(100% + var(--space-2)); left: 0; animation: a2k-rise var(--dur-mid) var(--ease) both; }
.a2k-menu__item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; height: var(--control-md);
  padding: 0 var(--space-2);
  background: transparent; border: 0;
  border-radius: var(--radius-xs);
  color: var(--text); text-align: left; text-decoration: none;
  font-size: var(--text-md); line-height: var(--leading-md);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.a2k-menu__item .a2k-icon { color: var(--text-3); }
.a2k-menu__item:hover, .a2k-menu__item.is-hover { background: var(--surface-hover); }
.a2k-menu__item:active { background: var(--surface-active); }
.a2k-menu__item:disabled { color: var(--text-disabled); cursor: not-allowed; background: transparent; }
.a2k-menu__item--danger { color: var(--negative); }
.a2k-menu__item--danger .a2k-icon { color: var(--negative); }
.a2k-menu__item .a2k-kbd { margin-left: auto; }
.a2k-menu__sep { height: var(--space-px); margin: var(--space-1) calc(-1 * var(--space-1)); background: var(--line); }
.a2k-popover { width: var(--popover-w); padding: var(--space-4); display: grid; gap: var(--space-2); }
.a2k-popover__title { font-weight: var(--weight-medium); }
.a2k-popover__text { color: var(--text-2); }

.a2k-toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: var(--z-toast); display: grid; gap: var(--space-2); }
.a2k-toast {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--space-3);
  width: min(var(--toast-w), 100%);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-size: var(--text-md); line-height: var(--leading-md);
}
.a2k-toast .a2k-dot { margin-top: var(--space-2); }
.a2k-toast__title { font-weight: var(--weight-medium); }
.a2k-toast__text { color: var(--text-2); }

/* Tooltip: above or below its trigger, never over it. Use --start or --end near a container edge so it stays inside. */
.a2k-tip { position: relative; display: inline-flex; }
.a2k-tip__body {
  position: absolute; bottom: calc(100% + var(--space-2)); left: 50%;
  translate: -50% 0;
  width: max-content; max-width: var(--tooltip-max);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-size: var(--text-xs); line-height: var(--leading-xs);
  color: var(--text); text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(var(--space-1));
  transition: opacity var(--dur-mid) var(--ease), transform var(--dur-mid) var(--ease), visibility var(--dur-mid) var(--ease);
  z-index: var(--z-popover);
}
.a2k-tip--start .a2k-tip__body { left: 0; translate: 0 0; }
.a2k-tip--end .a2k-tip__body { left: auto; right: 0; translate: 0 0; }
.a2k-tip--below .a2k-tip__body { bottom: auto; top: calc(100% + var(--space-2)); transform: translateY(calc(-1 * var(--space-1))); }
.a2k-tip:hover .a2k-tip__body, .a2k-tip:focus-within .a2k-tip__body, .a2k-tip.is-open .a2k-tip__body {
  opacity: 1; visibility: visible; transform: none;
}

/* ---------- 10. Product frame: a cropped screen built in code ---------- */
.a2k-frame {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  min-width: 0;
}
.a2k-frame__bar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--control-lg);
  padding-inline: var(--space-4);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--line);
}
.a2k-frame__body { display: grid; grid-template-columns: var(--popover-w) minmax(0, 1fr); }
.a2k-frame__nav { padding: var(--space-4); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-0-5); }
.a2k-frame__main { padding: var(--space-6); min-width: 0; display: grid; gap: var(--space-4); align-content: start; }

/* ---------- Phone tap targets: every tappable thing is at least 44px ---------- */
@media (max-width: 639px) {
  .a2k-logo, .a2k-skip { min-height: var(--control-lg); }
  .a2k-skip { display: inline-flex; align-items: center; }
  .a2k-crumbs a, .a2k-foot a, .a2k-meta a { display: inline-flex; align-items: center; min-height: var(--control-lg); }
  .a2k-btn--icon, .a2k-btn--icon.a2k-btn--sm, .a2k-btn--icon.a2k-btn--lg { width: var(--control-lg); }
  .a2k-check, .a2k-switch-row { min-height: var(--control-lg); align-items: center; }
  .a2k-check input[type="checkbox"], .a2k-check input[type="radio"] { margin-top: 0; }
  .a2k-tab, .a2k-segmented__item { min-width: var(--control-lg); justify-content: center; }
  .a2k-menu__item { height: var(--control-lg); }
  .a2k-header--hide-sm { display: none; }
  .a2k-page-header__actions { width: 100%; flex-direction: column; align-items: stretch; }
  .a2k-page-header__actions .a2k-btn { width: 100%; }
  .a2k-page-header__actions .a2k-btn--primary { order: 1; }
  .a2k-page-header__actions .a2k-btn--secondary { order: 2; }
  .a2k-card--flush .a2k-table td:first-child { padding-left: 0; }
  .a2k-card--flush .a2k-table td:last-child { padding-right: 0; }
  .a2k-card__foot { padding-inline: var(--space-1); }
  .a2k-page-header__actions .a2k-segmented { width: 100%; }
  .a2k-page-header__actions .a2k-segmented__item { flex: 1 1 0; }
}

/* ---------- 11. Utilities and motion ---------- */
/* Main chart two thirds, a narrower list beside it; one column below 1280. */
.a2k-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (max-width: 1279px) { .a2k-split { grid-template-columns: minmax(0, 1fr); } }
.a2k-split--stretch { align-items: stretch; }

.a2k-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.a2k-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.a2k-cluster--tight { gap: var(--space-2); }
.a2k-hairline { border: 0; border-top: 1px solid var(--line); margin: 0; }

@keyframes a2k-rise {
  from { opacity: 0; transform: translateY(var(--rise)); }
  to { opacity: 1; transform: none; }
}
/* One entrance on load: the main content fades and rises, at most six items, small stagger. */
.a2k-enter > * { animation: a2k-rise var(--dur-slow) var(--ease) both; animation-delay: calc(var(--i, 0) * var(--stagger)); }
.a2k-enter > *:nth-child(1) { --i: 0; }
.a2k-enter > *:nth-child(2) { --i: 1; }
.a2k-enter > *:nth-child(3) { --i: 2; }
.a2k-enter > *:nth-child(4) { --i: 3; }
.a2k-enter > *:nth-child(5) { --i: 4; }
.a2k-enter > *:nth-child(n+6) { --i: 5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .a2k-btn:active, .a2k-nav__item:active, .a2k-segmented__item:active, .a2k-pagination__btn:active,
  .a2k-tip__body, .a2k-btn.is-loading::before { transform: none !important; }
  .a2k-tip__body { transition-property: opacity, visibility; }
}
