/* ============================================================
   Synaptyx — Component primitives (Part 0)
   ============================================================
   Reads design tokens from tokens.css. No raw values.
   Class convention: BEM-ish, namespaced `sx-` for Synaptyx.
   ============================================================ */

/* ─── TYPOGRAPHY PRIMITIVES ──────────────────────────────────── */
.sx-display { font-family: var(--font-display); font-size: var(--fz-display); line-height: var(--lh-display); letter-spacing: var(--tr-display); font-weight: var(--fw-bold); color: var(--fg-primary); margin: 0; }
.sx-display em { font-style: italic; font-family: var(--font-serif); font-weight: var(--fw-regular); color: var(--accent); }
.sx-h1 { font-family: var(--font-display); font-size: var(--fz-h1); line-height: var(--lh-heading); letter-spacing: var(--tr-display); font-weight: var(--fw-medium); color: var(--fg-primary); margin: 0; }
.sx-h2 { font-family: var(--font-body); font-size: var(--fz-h2); line-height: var(--lh-heading); letter-spacing: var(--tr-body); font-weight: var(--fw-medium); color: var(--fg-primary); margin: 0; }
.sx-h3 { font-family: var(--font-body); font-size: var(--fz-h3); line-height: var(--lh-heading); font-weight: var(--fw-medium); color: var(--fg-primary); margin: 0; }
.sx-body { font-size: var(--fz-body); color: var(--fg-secondary); }
.sx-meta { font-size: var(--fz-meta); color: var(--fg-secondary); }
.sx-mono { font-family: var(--font-mono); font-size: var(--fz-mono-sm); color: var(--fg-secondary); }
.sx-overline { font-family: var(--font-mono); font-size: var(--fz-meta); letter-spacing: var(--tr-meta-upper); text-transform: uppercase; color: var(--fg-muted); font-weight: var(--fw-medium); }

/* ─── FOCUS ──────────────────────────────────────────────────── */
.sx-focusable:focus-visible,
.sx-btn:focus-visible,
.sx-input:focus-visible,
.sx-select:focus-visible,
.sx-textarea:focus-visible,
.sx-checkbox:focus-visible,
.sx-radio:focus-visible,
.sx-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* =====================================================================
   BUTTONS
   ===================================================================== */
.sx-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 36px;
  font-family: var(--font-body);
  font-size: var(--fz-body);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-3);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-primary);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-hover) var(--ease-out),
              border-color var(--dur-hover) var(--ease-out),
              color var(--dur-hover) var(--ease-out);
  user-select: none;
}
.sx-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sx-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Variants */
.sx-btn--primary {
  background: var(--accent);
  color: var(--fg-on-accent);
}
.sx-btn--primary:hover:not(:disabled)  { background: var(--accent-hover); }
.sx-btn--primary:active:not(:disabled) { background: var(--accent-active); }

.sx-btn--secondary {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--fg-primary);
}
.sx-btn--secondary:hover:not(:disabled) { background: var(--bg-surface-2); border-color: var(--border-strong); }

.sx-btn--ghost {
  background: transparent;
  color: var(--fg-primary);
}
.sx-btn--ghost:hover:not(:disabled) { background: var(--bg-surface-2); }

.sx-btn--danger {
  background: var(--danger);
  color: #fff;
}
.sx-btn--danger:hover:not(:disabled) { filter: brightness(1.08); }

.sx-btn--link {
  height: auto; padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.sx-btn--link:hover:not(:disabled) { color: var(--accent-hover); }

/* Sizes */
.sx-btn--sm { height: 28px; padding: 0 var(--space-3); font-size: var(--fz-meta); }
.sx-btn--sm svg { width: 14px; height: 14px; }
.sx-btn--lg { height: 44px; padding: 0 var(--space-5); font-size: 1rem; }
.sx-btn--lg svg { width: 18px; height: 18px; }

/* Icon-only square */
.sx-btn--icon { padding: 0; width: 36px; }
.sx-btn--icon.sx-btn--sm { width: 28px; }
.sx-btn--icon.sx-btn--lg { width: 44px; }

/* Loading state — width-stable spinner */
.sx-btn[data-loading="true"] { color: transparent; position: relative; }
.sx-btn[data-loading="true"]::after {
  content: ''; position: absolute; inset: 0;
  margin: auto; width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: sx-spin 0.7s linear infinite;
  color: var(--fg-on-accent);
}
.sx-btn--secondary[data-loading="true"]::after,
.sx-btn--ghost[data-loading="true"]::after { color: var(--fg-primary); }
@keyframes sx-spin { to { transform: rotate(360deg); } }

/* Split button */
.sx-split { display: inline-flex; }
.sx-split .sx-btn:first-child {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
  border-right: 1px solid color-mix(in srgb, var(--fg-on-accent) 20%, transparent);
}
.sx-split .sx-btn:last-child {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  padding: 0 var(--space-2); width: 32px;
}

/* Segmented button group */
.sx-seg {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  padding: 3px;
  gap: 2px;
}
.sx-seg button {
  height: 28px;
  padding: 0 var(--space-3);
  font-family: var(--font-body);
  font-size: var(--fz-meta);
  font-weight: var(--fw-medium);
  background: transparent;
  border: 0;
  color: var(--fg-secondary);
  border-radius: var(--radius-2);
  cursor: pointer;
  transition: background var(--dur-hover), color var(--dur-hover);
}
.sx-seg button:hover { color: var(--fg-primary); }
.sx-seg button[aria-pressed="true"] {
  background: var(--bg-surface-2);
  color: var(--fg-primary);
}

/* =====================================================================
   INPUTS
   ===================================================================== */
.sx-field { display: flex; flex-direction: column; gap: var(--space-2); }
.sx-label { font-size: var(--fz-meta); font-weight: var(--fw-medium); color: var(--fg-secondary); }
.sx-label .sx-req { color: var(--danger); margin-left: 2px; }
.sx-help { font-size: var(--fz-meta); color: var(--fg-muted); }
.sx-error-msg { font-size: var(--fz-meta); color: var(--danger); }

.sx-input,
.sx-textarea,
.sx-select {
  display: flex; align-items: center;
  height: 36px;
  padding: 0 var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  color: var(--fg-primary);
  font-family: var(--font-body);
  font-size: var(--fz-body);
  width: 100%;
  transition: border-color var(--dur-hover);
}
.sx-input::placeholder, .sx-textarea::placeholder { color: var(--fg-muted); }
.sx-input:hover, .sx-textarea:hover, .sx-select:hover { border-color: var(--border-strong); }
.sx-input:focus, .sx-textarea:focus, .sx-select:focus { outline: none; border-color: var(--accent); }
.sx-input:disabled, .sx-textarea:disabled, .sx-select:disabled { opacity: 0.5; cursor: not-allowed; background: var(--bg-surface-2); }
.sx-input[aria-invalid="true"], .sx-textarea[aria-invalid="true"] { border-color: var(--danger); }

.sx-textarea { height: auto; min-height: 80px; padding: var(--space-2) var(--space-3); resize: vertical; line-height: var(--lh-body); }

/* Mono input variant — for code, IDs, hosts */
.sx-input--mono { font-family: var(--font-mono); font-size: var(--fz-mono-sm); }

/* Input with leading icon + trailing */
.sx-input-group { position: relative; }
.sx-input-group .sx-input { padding-left: var(--space-7); }
.sx-input-group .sx-leading-icon {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--fg-muted); pointer-events: none;
}
.sx-input-group .sx-trailing {
  position: absolute; right: var(--space-2); top: 50%; transform: translateY(-50%);
  display: flex; gap: var(--space-1);
}

/* Native select chevron */
.sx-select {
  appearance: none; -webkit-appearance: none;
  padding-right: var(--space-7);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path stroke='%23a4a9b3' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round' d='M3 5l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

/* Toggle */
.sx-toggle {
  appearance: none; -webkit-appearance: none;
  position: relative;
  width: 36px; height: 20px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-hover), border-color var(--dur-hover);
  flex-shrink: 0;
}
.sx-toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--fg-secondary);
  border-radius: 50%;
  transition: left var(--dur-focus) var(--ease-emph), background var(--dur-focus);
}
.sx-toggle:checked { background: var(--accent); border-color: var(--accent); }
.sx-toggle:checked::after { left: 18px; background: var(--fg-on-accent); }

/* Checkbox */
.sx-checkbox {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--dur-hover), border-color var(--dur-hover);
}
.sx-checkbox:hover { border-color: var(--accent); }
.sx-checkbox:checked { background: var(--accent); border-color: var(--accent); }
.sx-checkbox:checked::after {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path stroke='white' stroke-width='1.75' fill='none' stroke-linecap='round' stroke-linejoin='round' d='M2 5l2 2 4-5'/></svg>");
  background-position: center; background-repeat: no-repeat;
}
.sx-checkbox:indeterminate { background: var(--accent); border-color: var(--accent); }
.sx-checkbox:indeterminate::after {
  content: ''; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path stroke='white' stroke-width='2' fill='none' stroke-linecap='round' d='M2 5h6'/></svg>");
  background-position: center; background-repeat: no-repeat;
}

/* Radio */
.sx-radio {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer; flex-shrink: 0; position: relative;
  transition: border-color var(--dur-hover);
}
.sx-radio:hover { border-color: var(--accent); }
.sx-radio:checked { border-color: var(--accent); border-width: 5px; }

.sx-choice {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--fz-body);
  color: var(--fg-primary);
  cursor: pointer;
}

/* Slider */
.sx-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-pill);
  outline: none;
}
.sx-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--bg-canvas);
  border-radius: 50%;
  cursor: pointer;
}

/* File drop */
.sx-dropzone {
  border: 1.5px dashed var(--border-default);
  border-radius: var(--radius-3);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  background: var(--bg-surface);
  transition: border-color var(--dur-hover), background var(--dur-hover);
}
.sx-dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.sx-dropzone[data-drag="true"] { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }

/* Tag input */
.sx-tag-input {
  display: flex; flex-wrap: wrap; gap: var(--space-1);
  padding: var(--space-1);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  min-height: 36px;
  align-items: center;
}
.sx-tag-input input { flex: 1; min-width: 80px; height: 26px; padding: 0 var(--space-2); background: transparent; border: 0; color: var(--fg-primary); font-family: var(--font-body); font-size: var(--fz-body); outline: none; }
.sx-tag-input input::placeholder { color: var(--fg-muted); }
.sx-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-1);
  font-family: var(--font-mono);
  font-size: var(--fz-meta);
  color: var(--fg-primary);
}
.sx-chip button { background: transparent; border: 0; color: var(--fg-muted); cursor: pointer; padding: 0; display: inline-flex; }
.sx-chip button:hover { color: var(--danger); }

/* =====================================================================
   SURFACES
   ===================================================================== */
.sx-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  overflow: hidden;
}
.sx-card__header,
.sx-card__footer { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.sx-card__footer { border-bottom: 0; border-top: 1px solid var(--border-subtle); }
.sx-card__body { padding: var(--space-5); }

/* Panel = full-bleed in layout */
.sx-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
}

/* Modal */
.sx-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  animation: sx-fade-in var(--dur-modal) var(--ease-out);
}
.sx-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-4);
  width: min(560px, calc(100vw - var(--space-6)));
  max-height: calc(100vh - var(--space-6));
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-3);
  animation: sx-modal-in var(--dur-modal) var(--ease-emph);
}
.sx-modal__header { padding: var(--space-5) var(--space-5) var(--space-3); }
.sx-modal__body   { padding: 0 var(--space-5) var(--space-5); }
.sx-modal__footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: var(--space-2); }
@keyframes sx-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sx-modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Popover */
.sx-popover {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  padding: var(--space-3);
  box-shadow: var(--shadow-2);
  min-width: 200px;
}

/* Tooltip */
.sx-tooltip {
  background: var(--fg-primary);
  color: var(--bg-canvas);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-1);
  font-size: var(--fz-meta);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-1);
}

/* =====================================================================
   BADGES / PILLS / STATUS
   ===================================================================== */
.sx-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--fz-meta);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  line-height: 1.4;
}
.sx-badge--neutral  { background: var(--bg-surface-2); border-color: var(--border-default); color: var(--fg-secondary); }
.sx-badge--success  { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.sx-badge--warning  { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.sx-badge--danger   { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.sx-badge--info     { background: var(--info-soft);    color: var(--info);    border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.sx-badge--accent   { background: var(--accent-soft);  color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

/* Outlined variants */
.sx-badge--outlined { background: transparent; }

/* Status dot */
.sx-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sx-dot--live    { background: var(--success); box-shadow: 0 0 6px color-mix(in srgb, var(--success) 60%, transparent); }
.sx-dot--idle    { background: var(--fg-muted); }
.sx-dot--warn    { background: var(--warning); }
.sx-dot--error   { background: var(--danger);  box-shadow: 0 0 6px color-mix(in srgb, var(--danger) 60%, transparent); }
.sx-dot--unknown { background: transparent; border: 1px solid var(--fg-muted); }

/* Health pill (traffic-light label combo) */
.sx-health {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 2px var(--space-2) 2px var(--space-1);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--fz-meta);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
}

/* Tier badge */
.sx-tier {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: var(--radius-1);
  border: 1px solid;
}
.sx-tier--community  { color: var(--tier-community);  border-color: var(--tier-community);  background: transparent; }
.sx-tier--team       { color: var(--fg-on-accent);    border-color: var(--tier-team);       background: var(--tier-team); }
.sx-tier--enterprise { color: var(--fg-on-accent);    border-color: var(--tier-enterprise); background: var(--tier-enterprise); }

/* Tenant chip */
.sx-tenant {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 2px var(--space-2);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-1);
  font-family: var(--font-mono);
  font-size: var(--fz-meta);
  color: var(--fg-primary);
}
.sx-tenant__swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* Avatar */
.sx-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-surface-2);
  color: var(--fg-primary);
  font-family: var(--font-mono);
  font-size: var(--fz-meta);
  font-weight: var(--fw-medium);
  border: 1px solid var(--border-default);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.sx-avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.sx-avatar--lg { width: 40px; height: 40px; font-size: var(--fz-body); }
.sx-avatar__status {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-canvas);
}
.sx-avatar-stack { display: inline-flex; }
.sx-avatar-stack .sx-avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--bg-canvas); }
.sx-avatar-stack .sx-avatar:first-child { margin-left: 0; }

/* KBD */
.sx-kbd {
  display: inline-flex; align-items: center; padding: 1px var(--space-1);
  min-width: 18px; height: 18px; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-1);
  color: var(--fg-secondary);
}

/* Cost number */
.sx-cost { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--fg-primary); }
.sx-cost__amt { font-size: var(--fz-body); font-weight: var(--fw-medium); }
.sx-cost__suffix { color: var(--fg-muted); font-size: var(--fz-meta); margin-left: 2px; }

/* Progress */
.sx-progress {
  width: 100%; height: 6px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.sx-progress__bar { height: 100%; background: var(--accent); transition: width var(--dur-focus) var(--ease-out); }
.sx-progress--seg { display: flex; gap: 2px; background: transparent; }
.sx-progress--seg span { flex: 1; height: 100%; background: var(--bg-surface-2); border-radius: 2px; }
.sx-progress--seg span[data-on="true"] { background: var(--accent); }

/* Spinner */
.sx-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--bg-surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sx-spin 0.7s linear infinite;
  display: inline-block;
}
.sx-spinner--sm { width: 12px; height: 12px; border-width: 1.5px; }
.sx-spinner--lg { width: 24px; height: 24px; border-width: 3px; }

/* Skeleton */
.sx-skel {
  background: linear-gradient(90deg,
    var(--bg-surface-2) 0%,
    color-mix(in srgb, var(--bg-surface-2) 60%, var(--border-default)) 50%,
    var(--bg-surface-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-1);
  animation: sx-skel 1.4s ease-in-out infinite;
}
.sx-skel--text { height: 12px; width: 100%; }
.sx-skel--text-sm { height: 10px; width: 60%; }
.sx-skel--card { height: 80px; width: 100%; }
@keyframes sx-skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =====================================================================
   TABLES
   ===================================================================== */
.sx-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  overflow: hidden;
  font-size: var(--fz-meta);
}
.sx-table th, .sx-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.sx-table tr:last-child td { border-bottom: 0; }
.sx-table th {
  font-size: 11px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tr-meta-upper);
  color: var(--fg-muted);
  background: var(--bg-surface-2);
  font-family: var(--font-mono);
  position: sticky; top: 0;
}
.sx-table tbody tr:hover { background: var(--bg-surface-2); }
.sx-table td { color: var(--fg-secondary); }
.sx-table td:first-child { color: var(--fg-primary); }

/* Description list */
.sx-dl { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-2) var(--space-5); }
.sx-dl dt { color: var(--fg-muted); font-size: var(--fz-meta); font-family: var(--font-mono); }
.sx-dl dd { color: var(--fg-primary); font-size: var(--fz-body); margin: 0; }

/* Stat card */
.sx-stat { display: flex; flex-direction: column; gap: var(--space-1); }
.sx-stat__label { font-family: var(--font-mono); font-size: var(--fz-meta); letter-spacing: var(--tr-meta-upper); text-transform: uppercase; color: var(--fg-muted); }
.sx-stat__value { font-family: var(--font-display); font-size: var(--fz-h1); line-height: 1.1; color: var(--fg-primary); font-variant-numeric: tabular-nums; letter-spacing: var(--tr-display); font-weight: var(--fw-bold); }
.sx-stat__delta { font-family: var(--font-mono); font-size: var(--fz-meta); display: inline-flex; align-items: center; gap: var(--space-1); }
.sx-stat__delta--up { color: var(--success); }
.sx-stat__delta--down { color: var(--danger); }
.sx-stat__delta--flat { color: var(--fg-muted); }

/* Code block */
.sx-code {
  position: relative;
  background: var(--term-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  font-family: var(--font-mono);
  font-size: var(--fz-mono-sm);
  color: var(--term-fg);
  overflow: hidden;
}
.sx-code__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid color-mix(in srgb, var(--term-fg) 15%, transparent);
  font-size: 11px; color: color-mix(in srgb, var(--term-fg) 70%, transparent);
}
.sx-code__body { padding: var(--space-3); overflow-x: auto; white-space: pre; line-height: 1.6; }
.sx-code__copy {
  background: transparent; border: 1px solid color-mix(in srgb, var(--term-fg) 20%, transparent);
  color: color-mix(in srgb, var(--term-fg) 80%, transparent);
  border-radius: var(--radius-1);
  padding: 2px var(--space-2);
  font-family: var(--font-mono); font-size: 11px;
  cursor: pointer;
}
.sx-code__copy:hover { color: var(--term-fg); border-color: var(--term-fg); }

/* =====================================================================
   NAVIGATION
   ===================================================================== */
.sx-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-4);
}
.sx-tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) 0;
  font-size: var(--fz-meta);
  font-weight: var(--fw-medium);
  color: var(--fg-secondary);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color var(--dur-tab), border-color var(--dur-tab);
}
.sx-tab:hover { color: var(--fg-primary); }
.sx-tab[aria-selected="true"] { color: var(--fg-primary); border-bottom-color: var(--accent); }
.sx-tab .sx-badge { margin-left: var(--space-1); }

/* Breadcrumb */
.sx-crumbs { display: flex; gap: var(--space-2); align-items: center; font-size: var(--fz-meta); color: var(--fg-muted); font-family: var(--font-mono); }
.sx-crumbs a { color: var(--fg-secondary); text-decoration: none; }
.sx-crumbs a:hover { color: var(--fg-primary); }
.sx-crumbs__sep { color: var(--fg-muted); }
.sx-crumbs > :last-child { color: var(--fg-primary); }

/* Stepper */
.sx-steps { display: flex; gap: 0; align-items: stretch; }
.sx-step { flex: 1; padding: var(--space-3) var(--space-4); border-bottom: 2px solid var(--border-default); display: flex; align-items: center; gap: var(--space-2); }
.sx-step__idx {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono); font-size: 11px; font-weight: var(--fw-medium);
  color: var(--fg-muted);
}
.sx-step__label { font-size: var(--fz-meta); color: var(--fg-muted); }
.sx-step[data-state="active"] { border-bottom-color: var(--accent); }
.sx-step[data-state="active"] .sx-step__idx { background: var(--accent); border-color: var(--accent); color: var(--fg-on-accent); }
.sx-step[data-state="active"] .sx-step__label { color: var(--fg-primary); font-weight: var(--fw-medium); }
.sx-step[data-state="done"] .sx-step__idx { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sx-step[data-state="done"] { border-bottom-color: var(--accent); }
.sx-step[data-state="done"] .sx-step__label { color: var(--fg-secondary); }

/* Top app bar */
.sx-appbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-5);
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}

/* Side nav */
.sx-sidenav { padding: var(--space-3); background: var(--bg-canvas); border-right: 1px solid var(--border-subtle); min-width: 220px; }
.sx-sidenav__group { margin-bottom: var(--space-5); }
.sx-sidenav__group-title { padding: 0 var(--space-3) var(--space-2); font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tr-meta-upper); text-transform: uppercase; color: var(--fg-muted); }
.sx-sidenav__item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-2);
  font-size: var(--fz-body);
  color: var(--fg-secondary);
  text-decoration: none;
  cursor: pointer;
}
.sx-sidenav__item:hover { background: var(--bg-surface-2); color: var(--fg-primary); }
.sx-sidenav__item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sx-sidenav__item[aria-current="page"] svg { color: var(--accent); }

/* =====================================================================
   FEEDBACK
   ===================================================================== */
.sx-toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-left-width: 3px;
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-2);
  min-width: 320px; max-width: 420px;
}
.sx-toast--success { border-left-color: var(--success); }
.sx-toast--warning { border-left-color: var(--warning); }
.sx-toast--danger  { border-left-color: var(--danger); }
.sx-toast--info    { border-left-color: var(--info); }
.sx-toast__icon { flex-shrink: 0; padding-top: 1px; }
.sx-toast__title { font-size: var(--fz-body); font-weight: var(--fw-medium); color: var(--fg-primary); }
.sx-toast__desc  { font-size: var(--fz-meta); color: var(--fg-secondary); margin-top: 2px; }
.sx-toast__close { margin-left: auto; background: transparent; border: 0; color: var(--fg-muted); cursor: pointer; padding: 0; }

/* Alert (inline) */
.sx-alert {
  display: flex; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-left-width: 3px;
  border-radius: var(--radius-3);
}
.sx-alert--success { border-left-color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, var(--border-default)); }
.sx-alert--warning { border-left-color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, var(--border-default)); }
.sx-alert--danger  { border-left-color: var(--danger);  background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 25%, var(--border-default)); }
.sx-alert--info    { border-left-color: var(--info);    background: var(--info-soft);    border-color: color-mix(in srgb, var(--info) 25%, var(--border-default)); }
.sx-alert__title { font-size: var(--fz-body); font-weight: var(--fw-medium); color: var(--fg-primary); }
.sx-alert__desc  { font-size: var(--fz-meta); color: var(--fg-secondary); margin-top: 2px; }

/* Empty state */
.sx-empty {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  max-width: 420px;
  margin: 0 auto;
}
.sx-empty__icon { color: var(--fg-muted); margin-bottom: var(--space-4); display: inline-flex; padding: var(--space-3); background: var(--bg-surface-2); border-radius: var(--radius-pill); }
.sx-empty__title { font-size: var(--fz-h3); font-weight: var(--fw-medium); color: var(--fg-primary); margin: 0; }
.sx-empty__desc  { font-size: var(--fz-body); color: var(--fg-secondary); margin-top: var(--space-2); margin-bottom: var(--space-4); }

/* ─── vt-0961 / Phase 4b composite layouts ───────────────────────
   Source: /tmp/agentfleet-design/company.html inline <style> block.
   Imported verbatim so the SPA modules can render composite chrome
   (dashboard stat cards, activity feed, onboarding, callouts,
   provider cards, CLAUDE.md editor, SIEM rule list, etc.) without
   inline styles in every module. */

/* Card grid */
.co-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }
.co-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.co-grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-3); }
@media (max-width: 900px) {
  .co-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .co-grid-3, .co-grid-2 { grid-template-columns: 1fr; }
}

/* Activity feed */
.co-act-feed { display: flex; flex-direction: column; }
.co-act-feed-row,
.co-act-row { display: grid; grid-template-columns: 28px 1fr auto; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); align-items: center; }
.co-act-feed-row:last-child, .co-act-row:last-child { border-bottom: 0; }
.co-act-feed-row .sx-avatar, .co-act-row .sx-avatar { width: 22px; height: 22px; font-size: 9px; }
.co-act-feed-row__body, .co-act-row__body { font-size: var(--fz-meta); color: var(--fg-secondary); line-height: 1.4; min-width: 0; }
.co-act-feed-row__body strong, .co-act-row__body strong { color: var(--fg-primary); font-weight: var(--fw-medium); }
.co-act-feed-row__time, .co-act-row__time { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-muted); white-space: nowrap; }

/* Onboarding checklist */
.co-onboard.is-collapsed .co-onboard__body { display: none; }
.co-onboard__row { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); align-items: center; font-size: var(--fz-meta); }
.co-onboard__row:last-child { border-bottom: 0; }
.co-onboard__check { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); color: transparent; flex-shrink: 0; }
.co-onboard__check.is-done { background: var(--accent); border-color: var(--accent); color: var(--fg-on-accent); }
.co-onboard__row.is-done { color: var(--fg-muted); text-decoration: line-through; }

/* Pending action callouts */
.co-callout {
  background: var(--accent-soft);
  border: 1px solid var(--border-default);
  border-left-width: 3px;
  border-radius: var(--radius-2);
  padding: var(--space-3) var(--space-4);
  display: flex; gap: var(--space-3); align-items: center;
}
.co-callout--warning { background: var(--warning-soft); }
.co-callout svg { color: var(--accent); flex-shrink: 0; }
.co-callout__title { font-size: var(--fz-meta); font-weight: var(--fw-medium); color: var(--fg-primary); }
.co-callout__body { font-size: 12px; color: var(--fg-secondary); margin-top: 2px; }

/* Inner tabs (Cost, SIEM, Teams drawer) */
.co-inner-tabs {
  display: flex; gap: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-5);
}
.co-inner-tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) 0;
  font-size: var(--fz-meta); font-weight: var(--fw-medium);
  color: var(--fg-secondary);
  background: transparent; border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.co-inner-tab:hover { color: var(--fg-primary); }
.co-inner-tab[aria-selected="true"] { color: var(--fg-primary); border-bottom-color: var(--accent); }

/* Modal */
.co-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.co-modal[hidden] { display: none; }
.co-modal__card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-4);
  box-shadow: var(--shadow-3);
  width: min(560px, 100%);
  max-height: calc(100vh - var(--space-7));
  display: flex; flex-direction: column;
  overflow: hidden;
}
.co-modal__card--wide { width: min(720px, 100%); }
.co-modal__head {
  padding: var(--space-5) var(--space-5) var(--space-3);
  display: flex; align-items: start; justify-content: space-between; gap: var(--space-3);
}
.co-modal__head h2 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: 1.375rem; line-height: 1.2; margin: 0 0 4px; color: var(--fg-primary); }
.co-modal__head p { font-size: var(--fz-meta); color: var(--fg-secondary); margin: 0; line-height: 1.5; }
.co-modal__body { padding: 0 var(--space-5) var(--space-4); overflow-y: auto; }
.co-modal__foot { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--space-2); justify-content: flex-end; }
.co-modal__close { background: transparent; border: 0; color: var(--fg-muted); cursor: pointer; padding: 4px; }
.co-modal__close:hover { color: var(--fg-primary); }

/* Form layout helpers */
.co-fields { display: flex; flex-direction: column; gap: var(--space-3); }
.co-fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 600px) { .co-fields-row { grid-template-columns: 1fr; } }

/* IdP / SIEM provider cards */
.co-card-list { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.co-prov-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  padding: var(--space-4);
}
.co-prov-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); gap: var(--space-2); }
.co-prov-card__icon { width: 36px; height: 36px; border-radius: var(--radius-2); display: inline-flex; align-items: center; justify-content: center; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); flex-shrink: 0; }
.co-prov-card__name { font-family: var(--font-body); font-weight: var(--fw-medium); font-size: 15px; color: var(--fg-primary); margin: 0; }
.co-prov-card__meta { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
.co-prov-card__row { display: flex; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) 0; font-size: 12px; color: var(--fg-secondary); }
.co-prov-card__row b { color: var(--fg-primary); font-weight: var(--fw-medium); font-family: var(--font-mono); }
.co-prov-card__actions { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--space-1); flex-wrap: wrap; }

/* CLAUDE.md editor */
.co-md-editor {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-3);
  background: var(--bg-surface);
  min-height: 520px;
  overflow: hidden;
}
@media (max-width: 1023px) { .co-md-editor { grid-template-columns: 1fr; } }
.co-md-pane { display: flex; flex-direction: column; }
.co-md-pane + .co-md-pane { border-left: 1px solid var(--border-subtle); }
.co-md-pane__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface-2); }
.co-md-pane__head span { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; color: var(--fg-muted); }
.co-md-area { flex: 1; padding: var(--space-3); background: var(--bg-canvas); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: var(--fg-primary); resize: none; border: 0; outline: 0; overflow: auto; }
.co-md-preview { flex: 1; padding: var(--space-4); overflow-y: auto; color: var(--fg-primary); }
.co-md-preview .frozen {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  padding: var(--space-2) var(--space-3);
  margin: var(--space-2) 0;
  border-radius: var(--radius-1);
}
.co-md-preview .frozen::before {
  content: 'FROZEN'; display: block; font-family: var(--font-mono); font-size: 9.5px; color: var(--accent); margin-bottom: 4px;
}

/* Version history sidebar (CLAUDE.md) */
.co-md-history { border-left: 1px solid var(--border-subtle); padding: var(--space-3); width: 260px; background: var(--bg-surface-2); overflow-y: auto; }
.co-md-history__row { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2); border-radius: var(--radius-2); cursor: pointer; }
.co-md-history__row:hover { background: var(--bg-surface); }
.co-md-history__row.is-current { background: var(--accent-soft); color: var(--accent); }

/* Filter rules drag list (SIEM) */
.co-rules-list { display: flex; flex-direction: column; gap: var(--space-2); }
.co-rule {
  display: grid; grid-template-columns: 28px 1fr auto; gap: var(--space-3); align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2);
}
.co-rule.is-dragging { opacity: 0.5; }
.co-rule__handle { color: var(--fg-muted); cursor: grab; display: inline-flex; align-items: center; justify-content: center; }
.co-rule__handle:active { cursor: grabbing; }
.co-rule__body { display: grid; grid-template-columns: 120px 1fr 120px; gap: var(--space-2); align-items: center; }
.co-rule__match { font-family: var(--font-mono); font-size: 12px; color: var(--fg-primary); background: var(--bg-surface-2); padding: 2px var(--space-2); border-radius: var(--radius-1); }
.co-rule__action { font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; gap: 4px; width: fit-content; }
.co-rule__action--include { background: var(--success-soft); color: var(--success); }
.co-rule__action--exclude { background: var(--danger-soft); color: var(--danger); }
.co-rule__action--transform { background: var(--accent-soft); color: var(--accent); }

/* Inline pill (read-only inline status in rows) */
.co-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px var(--space-2); border-radius: var(--radius-pill);
  font-family: var(--font-mono); font-size: 10.5px;
}

/* Subtle horizontal divider */
.co-divider { border-top: 1px solid var(--border-subtle); margin: var(--space-4) 0; }

/* Cost ledger virtualized table density */
.co-ledger td { font-size: 11.5px; padding: 6px var(--space-3); }
.co-ledger th { font-size: 10.5px; padding: 8px var(--space-3); }

/* Sub-section heading */
.co-subhead { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--fg-muted); margin: var(--space-5) 0 var(--space-3); }

/* Slide-from-right drawer (Teams / Users / per-row detail) */
.co-drawer {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(0,0,0,0.45);
  display: flex; justify-content: flex-end;
}
.co-drawer[hidden] { display: none; }
.co-drawer__card {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-default);
  width: min(640px, 100%);
  height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-3);
  animation: co-drawer-in 200ms var(--ease-emph);
}
.co-drawer__card--wide { width: min(840px, 100%); }
@keyframes co-drawer-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.co-drawer__head {
  padding: var(--space-5) var(--space-5) var(--space-3);
  display: flex; align-items: start; justify-content: space-between; gap: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.co-drawer__head h2 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: 1.25rem; line-height: 1.2; margin: 0; color: var(--fg-primary); }
.co-drawer__body { padding: var(--space-4) var(--space-5); overflow-y: auto; flex: 1; }
.co-drawer__foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--space-2); justify-content: flex-end; }

/* Stepper for multi-step modals (invite, enrol, add-IdP, add-SIEM) */
.co-step-dots { display: flex; gap: 6px; align-items: center; }
.co-step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-default); }
.co-step-dot.is-active { background: var(--accent); }
.co-step-dot.is-done { background: var(--success); }

/* Token-once box (enrol, scim, service-account, rotate) */
.co-token-once {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2);
  padding: var(--space-3);
  word-break: break-all;
  user-select: all;
}
.co-token-once__warn { color: var(--warning); font-weight: var(--fw-medium); font-family: var(--font-body); font-size: var(--fz-meta); margin-bottom: var(--space-2); }
.co-token-once__countdown { color: var(--danger); font-family: var(--font-mono); font-size: 11px; margin-top: var(--space-2); }
