/* Shared primitives (shared/ui/*.tsx): Button, Field/Input/Textarea/Checkbox/
   Switch, Tag, Tabs, EmptyState, Tooltip, PageHeader, Table, Pager, Drawer,
   Dialog, Toast, Banner, KpiCard, Skeleton.

   Every colour, radius, font and space comes from the design tokens in
   shared/ui/tokens.css; nothing here names a colour, so one stylesheet serves
   light and dark. Class prefix: cc-. Import once per console from its
   main.tsx, next to select.css. */

/* ── Utilities ─────────────────────────────────────────────────────── */
.cc-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@keyframes cc-spin { to { transform: rotate(360deg); } }
@keyframes cc-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cc-pop-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cc-slide-in-right { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes cc-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.cc-spin { animation: cc-spin .8s linear infinite; }

.cc-iconbtn {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 28px; height: 28px; padding: 0;
  color: var(--fg-muted); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer;
}
.cc-iconbtn:hover { color: var(--fg); background: var(--bg-sunken); }
.cc-iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.cc-doclink {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--accent-fg); font-weight: 500; text-decoration: none; text-underline-offset: 2px; white-space: nowrap;
}
.cc-doclink:hover { text-decoration: underline; }
.cc-doclink:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); border-radius: 2px; }

/* Full-viewport layers (Dialog, Drawer) and their overlay. */
.cc-layer { position: fixed; inset: 0; display: flex; }
.cc-overlay { position: absolute; inset: 0; background: var(--bg-overlay); animation: cc-fade-in .15s ease-out; }

/* ── Button ────────────────────────────────────────────────────────── */
.cc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 32px; padding: 0 var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 500; line-height: 1;
  white-space: nowrap; text-decoration: none; user-select: none;
  color: var(--fg); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.cc-btn--sm { height: 28px; padding: 0 var(--space-2); gap: 6px; font-size: var(--text-xs); }
.cc-btn--icon { width: 32px; padding: 0; }
.cc-btn--sm.cc-btn--icon { width: 28px; }
.cc-btn--full { display: flex; width: 100%; }
.cc-btn__icon { display: inline-flex; flex: 0 0 auto; }
.cc-btn__icon > svg { display: block; }
.cc-btn__label { display: inline-block; }
.cc-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.cc-btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(1px); }
.cc-btn:disabled, .cc-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.cc-btn.is-loading { cursor: progress; }

.cc-btn--secondary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--bg-sunken); border-color: var(--border-strong); }

.cc-btn--primary { color: var(--fg-on-accent); background: var(--accent); border-color: var(--accent); }
.cc-btn--primary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--accent-hover); border-color: var(--accent-hover); }

.cc-btn--ghost { color: var(--fg-muted); background: transparent; border-color: transparent; }
.cc-btn--ghost:hover:not(:disabled):not([aria-disabled="true"]) { color: var(--fg); background: var(--bg-sunken); }

.cc-btn--danger { color: var(--fg-on-accent); background: var(--danger); border-color: var(--danger); }
.cc-btn--danger:hover:not(:disabled):not([aria-disabled="true"]) { filter: brightness(.92); }

/* ── Field / Input / Textarea ──────────────────────────────────────── */
.cc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cc-field--inline { flex-direction: row; align-items: center; gap: var(--space-3); }
.cc-field__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.cc-field__label { font-size: var(--text-sm); font-weight: 500; color: var(--fg); }
.cc-field__req { margin-left: 3px; color: var(--danger); }
.cc-field__aside { font-size: var(--text-xs); color: var(--fg-subtle); }
.cc-field__control { min-width: 0; }
.cc-field--inline .cc-field__control { flex: 1 1 auto; }
.cc-field__hint { font-size: var(--text-xs); line-height: var(--leading-normal); color: var(--fg-muted); }
.cc-field__error { font-size: var(--text-xs); line-height: var(--leading-normal); color: var(--danger); }
.cc-field.is-disabled .cc-field__label { color: var(--fg-subtle); }

.cc-input {
  display: block; width: 100%; min-width: 0; height: 32px; padding: 0 10px;
  font-family: var(--font-sans); font-size: var(--text-sm); line-height: 1.3;
  color: var(--fg); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; appearance: none;
  transition: border-color .12s, box-shadow .12s;
}
.cc-input--sm { height: 28px; padding: 0 8px; font-size: var(--text-xs); }
.cc-input--mono { font-family: var(--font-mono); font-size: calc(var(--text-sm) - 1px); font-variant-numeric: tabular-nums; }
.cc-input::placeholder { color: var(--fg-subtle); }
.cc-input:hover:not(:disabled):not(:focus) { border-color: var(--border-strong); }
.cc-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.cc-input[aria-invalid="true"] { border-color: var(--danger); }
.cc-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.cc-input:disabled { opacity: .5; cursor: not-allowed; background: var(--bg-sunken); }
.cc-textarea { height: auto; min-height: 72px; padding: 8px 10px; line-height: var(--leading-normal); resize: vertical; }

.cc-input-wrap {
  display: flex; align-items: center; width: 100%;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
.cc-input-wrap .cc-input { flex: 1 1 auto; height: 30px; border: 0; background: transparent; box-shadow: none; }
.cc-input-wrap.cc-input--sm .cc-input { height: 26px; }
.cc-input-wrap:hover:not(.is-disabled):not(:focus-within) { border-color: var(--border-strong); }
.cc-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.cc-input-wrap.is-invalid { border-color: var(--danger); }
.cc-input-wrap.is-invalid:focus-within { box-shadow: 0 0 0 3px var(--danger-soft); }
.cc-input-wrap.is-disabled { opacity: .5; background: var(--bg-sunken); }
.cc-input__affix { display: inline-flex; align-items: center; padding: 0 10px; font-size: var(--text-xs); color: var(--fg-muted); white-space: nowrap; }
.cc-input-wrap .cc-input__affix:first-child { padding-right: 0; }
.cc-input-wrap .cc-input__affix:last-child { padding-left: 0; }

/* ── Checkbox / Switch ─────────────────────────────────────────────── */
.cc-check { position: relative; display: inline-flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-sm); color: var(--fg); cursor: pointer; }
.cc-check.is-disabled { opacity: .5; cursor: not-allowed; }
.cc-check__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.cc-check__box {
  display: inline-grid; place-items: center; flex: 0 0 16px; width: 16px; height: 16px; margin-top: 1px;
  color: var(--fg-on-accent); background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: background-color .12s, border-color .12s;
}
.cc-check__box > svg { opacity: 0; }
.cc-check__input:checked + .cc-check__box,
.cc-check__input:indeterminate + .cc-check__box { background: var(--accent); border-color: var(--accent); }
.cc-check__input:checked + .cc-check__box > svg,
.cc-check__input:indeterminate + .cc-check__box > svg { opacity: 1; }
.cc-check__input:focus-visible + .cc-check__box { box-shadow: 0 0 0 3px var(--ring); }
.cc-check__input[aria-invalid="true"] + .cc-check__box { border-color: var(--danger); }
.cc-check__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-check__label { line-height: 1.3; }
.cc-check__desc { font-size: var(--text-xs); line-height: var(--leading-normal); color: var(--fg-muted); }

.cc-switch {
  position: relative; flex: 0 0 auto; width: 32px; height: 18px; padding: 0;
  background: var(--border-strong); border: 1px solid transparent; border-radius: var(--radius-full);
  cursor: pointer; transition: background-color .15s;
}
.cc-switch--sm { width: 26px; height: 15px; }
.cc-switch__thumb {
  position: absolute; top: 1px; left: 1px; width: 14px; height: 14px;
  background: var(--bg-elevated); border-radius: 50%; box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.cc-switch--sm .cc-switch__thumb { width: 11px; height: 11px; }
.cc-switch.is-on { background: var(--accent); }
.cc-switch.is-on .cc-switch__thumb { transform: translateX(14px); }
.cc-switch--sm.is-on .cc-switch__thumb { transform: translateX(11px); }
.cc-switch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.cc-switch:disabled { opacity: .5; cursor: not-allowed; }
.cc-switch-row { display: inline-flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-sm); color: var(--fg); }
.cc-switch-row .cc-switch { margin-top: 1px; }
.cc-switch-row .cc-check__text { cursor: pointer; }
.cc-switch-row.is-disabled { opacity: .5; }
.cc-switch-row.is-disabled .cc-check__text { cursor: not-allowed; }

/* ── Tag ───────────────────────────────────────────────────────────── */
.cc-tag {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 6px;
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1; font-variant-numeric: tabular-nums;
  white-space: nowrap; vertical-align: middle;
  color: var(--fg-muted); background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cc-tag--sm { height: 18px; padding: 0 5px; font-size: calc(var(--text-xs) - 1px); }
.cc-tag--sans { font-family: var(--font-sans); font-weight: 500; }
.cc-tag__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cc-tag--ok { color: var(--ok); background: var(--ok-soft); }
.cc-tag--warn { color: var(--warn); background: var(--warn-soft); }
.cc-tag--danger { color: var(--danger); background: var(--danger-soft); }
.cc-tag--info { color: var(--info); background: var(--info-soft); }
.cc-tag--accent { color: var(--accent-fg); background: var(--accent-soft); }
.cc-tag--ok, .cc-tag--warn, .cc-tag--danger, .cc-tag--info, .cc-tag--accent {
  border-color: color-mix(in srgb, currentColor 28%, transparent);
}

/* ── Tabs ──────────────────────────────────────────────────────────── */
.cc-tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; border-bottom: 1px solid var(--border); }
/* overflow-x makes the bar's minimum height 0, so in a flex column a tall
   panel below squeezed it out of sight (MoQT inspector, Messages tab). */
.cc-tabs--horizontal { flex-shrink: 0; }
.cc-tabs--vertical { flex-direction: column; overflow: visible; border-bottom: 0; border-right: 1px solid var(--border); }
.cc-tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 var(--space-3); margin-bottom: -1px;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
  color: var(--fg-muted); background: transparent;
  border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  transition: color .12s, border-color .12s;
}
.cc-tabs--sm .cc-tab { height: 30px; padding: 0 var(--space-2); font-size: var(--text-xs); }
.cc-tab:hover:not(:disabled) { color: var(--fg); }
.cc-tab.is-selected { color: var(--fg); border-bottom-color: var(--accent); }
.cc-tab:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); border-radius: var(--radius-sm); }
.cc-tab:disabled { opacity: .45; cursor: not-allowed; }
.cc-tab__icon { display: inline-flex; }
.cc-tab__count {
  padding: 0 5px; line-height: 16px;
  font-family: var(--font-mono); font-size: calc(var(--text-xs) - 1px); font-variant-numeric: tabular-nums;
  color: var(--fg-subtle); background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cc-tab.is-selected .cc-tab__count { color: var(--fg-muted); }
.cc-tabs--vertical .cc-tab { justify-content: flex-start; height: 32px; margin: 0 -1px 0 0; border-bottom: 0; border-right: 2px solid transparent; }
.cc-tabs--vertical .cc-tab.is-selected { border-right-color: var(--accent); }
.cc-tabs--segmented {
  width: max-content; max-width: 100%; gap: 2px; padding: 2px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.cc-tabs--segmented .cc-tab { height: 26px; margin: 0; padding: 0 10px; font-size: var(--text-xs); border: 0; border-radius: var(--radius-sm); }
.cc-tabs--segmented .cc-tab.is-selected { color: var(--fg); background: var(--bg-elevated); box-shadow: var(--shadow-sm); }
.cc-tabpanel:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); border-radius: var(--radius-sm); }

/* ── EmptyState ────────────────────────────────────────────────────── */
.cc-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3);
  min-height: 0; padding: var(--space-8) var(--space-6); text-align: center;
}
.cc-empty--compact { gap: var(--space-2); padding: var(--space-6) var(--space-4); }
.cc-empty__icon {
  display: grid; place-items: center; width: 40px; height: 40px;
  color: var(--fg-muted); background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.cc-empty__icon > svg { width: 20px; height: 20px; }
.cc-empty__title { font-size: var(--text-md); font-weight: 600; color: var(--fg); }
.cc-empty--compact .cc-empty__title { font-size: var(--text-sm); }
.cc-empty__body { max-width: 440px; font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--fg-muted); }
.cc-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-1); }
.cc-empty__doc { font-size: var(--text-xs); }

/* ── PageHeader ────────────────────────────────────────────────────── */
.cc-pagehead { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; margin-bottom: var(--space-5); }
.cc-pagehead__row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.cc-pagehead__text { display: flex; flex: 1 1 320px; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cc-pagehead__title {
  margin: 0; font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em;
  line-height: var(--leading-tight); color: var(--fg);
}
.cc-pagehead__sub {
  margin: 0; font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--fg-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-pagehead__doc { margin-left: var(--space-1); }
.cc-pagehead__actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cc-crumbs { font-size: var(--text-xs); color: var(--fg-muted); }
.cc-crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cc-crumbs li { display: inline-flex; align-items: center; gap: 2px; }
.cc-crumbs a, .cc-crumbs button { padding: 0; font: inherit; color: var(--fg-muted); background: none; border: 0; text-decoration: none; cursor: pointer; }
.cc-crumbs a:hover, .cc-crumbs button:hover { color: var(--fg); text-decoration: underline; }
.cc-crumbs__sep { display: inline-flex; color: var(--fg-subtle); }

/* ── Table ─────────────────────────────────────────────────────────── */
.cc-table-frame {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
}
.cc-table-frame--bare { background: transparent; border: 0; border-radius: 0; }
.cc-table-scroll { max-width: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.cc-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); color: var(--fg); }
.cc-table th {
  height: 36px; padding: 0 var(--space-3); text-align: left; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500;
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--fg-muted); background: var(--bg-sunken); border-bottom: 1px solid var(--border);
}
.cc-table--sticky th { position: sticky; top: 0; z-index: 1; }
.cc-table td { height: 44px; padding: 0 var(--space-3); vertical-align: middle; line-height: var(--leading-normal); border-bottom: 1px solid var(--border); }
.cc-table--compact th { height: 32px; }
.cc-table--compact td { height: 36px; }
.cc-table tbody tr:last-child td { border-bottom: 0; }
.cc-table th.is-right, .cc-table td.is-right { text-align: right; }
.cc-table th.is-center, .cc-table td.is-center { text-align: center; }
.cc-table td.is-mono { font-family: var(--font-mono); font-size: calc(var(--text-sm) - 1px); font-variant-numeric: tabular-nums; }
.cc-table td.is-nowrap { white-space: nowrap; }
.cc-table tbody tr.is-clickable { cursor: pointer; }
.cc-table tbody tr.is-clickable:hover td { background: var(--bg-sunken); }
.cc-table tbody tr.is-clickable:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
.cc-table.is-refreshing tbody { opacity: .6; transition: opacity .15s; }
.cc-table__sort {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 calc(-1 * var(--space-1)); padding: 2px var(--space-1);
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.cc-table__sort:hover { color: var(--fg); }
.cc-table__sort:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.cc-table__sorticon { display: inline-flex; color: var(--fg-subtle); }
.cc-table th.is-sorted .cc-table__sort { color: var(--fg); }
.cc-table th.is-sorted .cc-table__sorticon { color: var(--accent-fg); }
.cc-table__null { color: var(--fg-subtle); }
.cc-table__emptyrow td { height: auto; padding: 0; }
.cc-table__empty { padding: var(--space-6); font-size: var(--text-sm); text-align: center; color: var(--fg-muted); }
.cc-table-footer { background: var(--bg-elevated); border-top: 1px solid var(--border); }
.cc-table-footer .cc-pager { border-top: 0; }

/* ── Pager ─────────────────────────────────────────────────────────── */
.cc-pager {
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs); color: var(--fg-muted); border-top: 1px solid var(--border);
}
.cc-pager--bare { padding-left: 0; padding-right: 0; border-top: 0; }
.cc-pager__pos { padding: 0 var(--space-1); font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cc-pager__pos strong { font-weight: 600; color: var(--fg); }
.cc-pager__total { margin-left: auto; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--fg-subtle); white-space: nowrap; }

/* ── ListToolbar ───────────────────────────────────────────────────── */
.cc-listbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
  font-size: var(--text-xs); color: var(--fg-muted);
}
.cc-listbar__search { flex: 1 1 220px; max-width: 320px; }
.cc-listbar__clear { display: grid; place-items: center; padding: 2px; border: 0; background: none; color: var(--fg-subtle); cursor: pointer; }
.cc-listbar__clear-slot { display: inline-grid; place-items: center; min-width: 16px; }
.cc-listbar__group { display: inline-flex; align-items: center; gap: var(--space-1); }
.cc-listbar__label { color: var(--fg-subtle); white-space: nowrap; }
.cc-listbar__seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cc-listbar__chip {
  padding: 3px 9px; border: 0; background: none; color: var(--fg-muted); font: inherit; cursor: pointer; white-space: nowrap;
}
.cc-listbar__chip + .cc-listbar__chip { border-left: 1px solid var(--border); }
.cc-listbar__chip:hover { color: var(--fg); background: var(--bg-sunken); }
/* --accent-fg is ink for a SOLID accent fill; on these light fills use --fg / --accent. */
.cc-listbar__chip.is-on { color: var(--fg); background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.cc-listbar__n { margin-left: 5px; font-family: var(--font-mono); color: var(--fg-subtle); }
.cc-listbar__custom { display: inline-flex; align-items: center; gap: var(--space-1); }
.cc-listbar__dt {
  height: 26px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-elevated); color: var(--fg); font: inherit; color-scheme: light dark;
}
.cc-listbar__meta { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--fg-subtle); white-space: nowrap; }
.cc-listbar__reset { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.cc-listbar__actions { display: inline-flex; align-items: center; gap: var(--space-2); margin-left: auto; }

/* ── Skeleton ──────────────────────────────────────────────────────── */
.cc-skeleton {
  display: inline-block; vertical-align: middle;
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%; border-radius: var(--radius-sm);
  animation: cc-shimmer 1.4s linear infinite;
}
.cc-skeleton--line { width: 100%; height: 12px; }
.cc-skeleton--block { display: block; width: 100%; height: 80px; border-radius: var(--radius-md); }
.cc-skeleton-lines { display: flex; flex-direction: column; gap: 8px; width: 100%; }

/* ── Banner ────────────────────────────────────────────────────────── */
.cc-banner {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--fg);
  background: var(--bg-elevated); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-md);
}
.cc-banner--compact { gap: var(--space-2); padding: var(--space-2) var(--space-3); }
.cc-banner__icon { display: inline-flex; flex: 0 0 auto; margin-top: 1px; }
.cc-banner--info { border-left-color: var(--info); }
.cc-banner--info .cc-banner__icon { color: var(--info); }
.cc-banner--warn { border-left-color: var(--warn); }
.cc-banner--warn .cc-banner__icon { color: var(--warn); }
.cc-banner--danger { border-left-color: var(--danger); }
.cc-banner--danger .cc-banner__icon { color: var(--danger); }
.cc-banner--ok { border-left-color: var(--ok); }
.cc-banner--ok .cc-banner__icon { color: var(--ok); }
.cc-banner__text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.cc-banner__title { font-weight: 600; }
.cc-banner__body { color: var(--fg-muted); }
.cc-banner__action { display: inline-flex; flex: 0 0 auto; align-items: center; }
.cc-banner__close {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 24px; height: 24px; margin: -2px -4px -2px 0; padding: 0;
  color: var(--fg-subtle); background: transparent; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.cc-banner__close:hover { color: var(--fg); background: var(--bg-sunken); }
.cc-banner__close:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }

/* ── KpiCard ───────────────────────────────────────────────────────── */
.cc-kpi {
  position: relative; display: flex; flex-direction: column; gap: var(--space-1);
  min-width: 150px; padding: var(--space-3) var(--space-4); text-align: left;
  font-family: var(--font-sans); color: var(--fg);
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
}
.cc-kpi--sm { min-width: 120px; padding: var(--space-2) var(--space-3); }
.cc-kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: transparent; }
.cc-kpi--ok::before { background: var(--ok); }
.cc-kpi--warn::before { background: var(--warn); }
.cc-kpi--danger::before { background: var(--danger); }
.cc-kpi--interactive { cursor: pointer; }
.cc-kpi--interactive:hover { border-color: var(--border-strong); }
.cc-kpi--interactive:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.cc-kpi__label {
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cc-kpi__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.cc-kpi__value { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cc-kpi--sm .cc-kpi__value { font-size: var(--text-xl); }
.cc-kpi--ok .cc-kpi__value { color: var(--ok); }
.cc-kpi--warn .cc-kpi__value { color: var(--warn); }
.cc-kpi--danger .cc-kpi__value { color: var(--danger); }
.cc-kpi.is-empty .cc-kpi__value { color: var(--fg-subtle); }
.cc-kpi__unit { margin-left: 4px; font-size: var(--text-sm); font-weight: 500; letter-spacing: 0; color: var(--fg-muted); }
.cc-kpi__delta { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: var(--text-xs); font-variant-numeric: tabular-nums; color: var(--fg-muted); }
.cc-kpi__delta--ok { color: var(--ok); }
.cc-kpi__delta--warn { color: var(--warn); }
.cc-kpi__delta--danger { color: var(--danger); }
.cc-kpi__hint { font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-kpi__extra { display: block; margin-top: var(--space-1); }

/* ── Tooltip ───────────────────────────────────────────────────────── */
.cc-tooltip {
  position: fixed; max-width: 260px; padding: 5px 8px;
  font-family: var(--font-sans); font-size: var(--text-xs); line-height: var(--leading-normal); white-space: nowrap;
  color: var(--fg); background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  pointer-events: none; animation: cc-fade-in .1s ease-out;
}
.cc-tooltip--wide { max-width: 320px; white-space: normal; }

/* ── Menu (menu.tsx) ───────────────────────────────────────────────── */
.cc-menu {
  position: fixed; display: flex; flex-direction: column; gap: 1px;
  min-width: 200px; max-width: min(320px, calc(100vw - 16px)); max-height: calc(100dvh - 16px);
  padding: var(--space-1); overflow-y: auto; overscroll-behavior: contain;
  font-family: var(--font-sans); font-size: var(--text-sm); line-height: var(--leading-tight); color: var(--fg);
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); outline: none; animation: cc-pop-in .12s ease-out;
}
.cc-menu__item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 32px; padding: 6px var(--space-2);
  font: inherit; color: inherit; text-align: left; text-decoration: none; white-space: nowrap;
  background: transparent; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.cc-menu__item:hover, .cc-menu__item:focus { outline: none; background: var(--bg-sunken); }
.cc-menu__item:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }
.cc-menu__item[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.cc-menu__item.is-current { font-weight: 500; }
.cc-menu__item--danger { color: var(--danger); }
.cc-menu__item--danger .cc-menu__icon { color: var(--danger); }
.cc-menu__icon { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 16px; height: 16px; color: var(--fg-muted); }
.cc-menu__icon > svg { width: 16px; height: 16px; }
.cc-menu__item.is-current .cc-menu__icon { color: var(--accent); }
.cc-menu__check { display: inline-flex; flex: 0 0 auto; width: 14px; color: var(--accent); }
.cc-menu__text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cc-menu__trail { display: inline-flex; flex: 0 0 auto; align-items: center; gap: var(--space-1); margin-left: auto; font-size: var(--text-xs); color: var(--fg-subtle); }
.cc-menu__label { padding: 6px var(--space-2) 4px; font-size: var(--text-xs); font-weight: 500; color: var(--fg-subtle); }
.cc-menu__sep { flex: 0 0 auto; height: 1px; margin: var(--space-1) calc(-1 * var(--space-1)); background: var(--border); }
.cc-menu__group { display: flex; flex-direction: column; gap: 1px; }

/* ── Drawer ────────────────────────────────────────────────────────── */
.cc-drawer-layer { justify-content: flex-end; }
.cc-drawer {
  position: relative; display: flex; flex-direction: column; height: 100%; max-width: 100vw;
  background: var(--bg-elevated); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
  outline: none; animation: cc-slide-in-right .18s ease-out;
}
.cc-drawer__head {
  display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.cc-drawer__headtext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-drawer__title { margin: 0; font-size: var(--text-lg); font-weight: 600; line-height: var(--leading-tight); color: var(--fg); }
.cc-drawer__desc { margin: 0; font-size: var(--text-sm); color: var(--fg-muted); }
.cc-drawer__floatclose { position: absolute; top: var(--space-3); right: var(--space-3); z-index: 1; background: var(--bg-elevated); }
.cc-drawer__body { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow: auto; }
.cc-drawer__body.is-padded { padding: var(--space-5); }
.cc-drawer__foot {
  display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); background: var(--bg); border-top: 1px solid var(--border);
}

/* ── Dialog ────────────────────────────────────────────────────────── */
.cc-dialog-layer { align-items: center; justify-content: center; padding: var(--space-4); }
.cc-dialog {
  position: relative; display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 2 * var(--space-4));
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  outline: none; animation: cc-pop-in .15s ease-out;
}
.cc-dialog--sm { max-width: 400px; }
.cc-dialog--md { max-width: 480px; }
.cc-dialog--lg { max-width: 640px; }
.cc-dialog__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) var(--space-5) 0; }
.cc-dialog__tone { display: inline-grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-full); }
.cc-dialog__headtext { display: flex; flex: 1 1 auto; flex-direction: column; gap: 4px; min-width: 0; padding-right: var(--space-6); }
.cc-dialog__title { margin: 0; font-size: var(--text-lg); font-weight: 600; line-height: var(--leading-tight); color: var(--fg); }
.cc-dialog__desc { margin: 0; font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--fg-muted); }
.cc-dialog__body { min-height: 0; padding: var(--space-4) var(--space-5) 0; overflow: auto; font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--fg); }
.cc-dialog__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: var(--space-5); }
.cc-dialog__close { position: absolute; top: var(--space-3); right: var(--space-3); }

/* ── Toast ─────────────────────────────────────────────────────────── */
.cc-toasts {
  position: fixed; display: flex; flex-direction: column; gap: var(--space-2);
  width: min(380px, calc(100vw - 2 * var(--space-4))); pointer-events: none;
}
.cc-toasts--bottom-right { right: var(--space-4); bottom: var(--space-4); }
.cc-toasts--bottom-left { left: var(--space-4); bottom: var(--space-4); }
.cc-toasts--top-right { right: var(--space-4); top: calc(var(--topbar-h) + var(--space-3)); }
.cc-toast {
  display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3);
  font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--fg);
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-left-width: 3px; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  pointer-events: auto; animation: cc-pop-in .15s ease-out;
}
.cc-toast--ok { border-left-color: var(--ok); }
.cc-toast--warn { border-left-color: var(--warn); }
.cc-toast--danger { border-left-color: var(--danger); }
.cc-toast--info { border-left-color: var(--info); }
.cc-toast__icon { display: inline-flex; flex: 0 0 auto; margin-top: 1px; }
.cc-toast--ok .cc-toast__icon { color: var(--ok); }
.cc-toast--warn .cc-toast__icon { color: var(--warn); }
.cc-toast--danger .cc-toast__icon { color: var(--danger); }
.cc-toast--info .cc-toast__icon { color: var(--info); }
.cc-toast__text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.cc-toast__msg { font-weight: 500; overflow-wrap: anywhere; }
.cc-toast__desc { font-size: var(--text-xs); color: var(--fg-muted); overflow-wrap: anywhere; }
.cc-toast__action {
  flex: 0 0 auto; height: 24px; padding: 0 8px; font: inherit; font-size: var(--text-xs); font-weight: 500;
  color: var(--accent-fg); background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.cc-toast__action:hover { background: var(--bg-sunken); }
.cc-toast__action:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.cc-toast__close { width: 24px; height: 24px; margin: -2px -4px -2px 0; }

/* ── Motion ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cc-overlay, .cc-dialog, .cc-drawer, .cc-toast, .cc-tooltip, .cc-menu { animation: none; }
  .cc-skeleton { animation: none; }
  .cc-btn, .cc-input, .cc-input-wrap, .cc-tab, .cc-switch, .cc-switch__thumb, .cc-check__box { transition: none; }
}
