/**
 * AV Design System — Components (Wave 1)
 * Source: @sgeo/ui-kit v4.0 (.tsx) → handwritten CSS
 * Tokens come from tokens.css + total-overlay.css
 * Prefix: .av-*  (coexists with .qs-* and legacy Total classes)
 *
 * Components:
 *   .av-btn       (primary/secondary/ghost/outline/destructive/link × sm/md/lg/icon)
 *   .av-input     (+ __label, __hint, __error, __wrapper, __addon, __icon)
 *   .av-textarea
 *   .av-select
 *   .av-checkbox
 *   .av-switch    (sm/md)
 *   .av-alert     (info/success/warning/error)
 *   .av-badge     (default/secondary/outline/success/warning/danger/info/neutral × sm/md/lg)
 *   .av-card      (default/elevated/outline/ghost × none/sm/md/lg)
 *   .av-divider
 */

/* ============================================================
   BUTTON  — .av-btn
   ============================================================ */
.av-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
  border-radius: calc(var(--av-radius) - 2px); /* ~0.375rem */
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
  text-decoration: none;
}
.av-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}
.av-btn:disabled,
.av-btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
.av-btn--full-width {
  width: 100%;
}

/* Sizes */
.av-btn--sm {
  height: 1.75rem;
  padding: 0 0.625rem;
  font-size: 0.75rem;
  line-height: 1rem;
}
.av-btn--md {
  height: 2.125rem;
  padding: 0 0.875rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}
.av-btn--lg {
  height: 2.625rem;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.375rem;
}
.av-btn--icon {
  height: 2.125rem;
  width: 2.125rem;
  padding: 0;
}
.av-btn--icon.av-btn--sm {
  height: 1.75rem;
  width: 1.75rem;
}
.av-btn--icon.av-btn--lg {
  height: 2.625rem;
  width: 2.625rem;
}

/* Variants */
.av-btn--primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.av-btn--primary:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.9);
  border-color: hsl(var(--primary) / 0.9);
}

.av-btn--secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.av-btn--secondary:hover:not(:disabled) {
  background: hsl(var(--secondary) / 0.8);
}

.av-btn--ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: transparent;
}
.av-btn--ghost:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.av-btn--outline {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.av-btn--outline:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.av-btn--destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: hsl(var(--destructive));
}
.av-btn--destructive:hover:not(:disabled) {
  background: hsl(var(--destructive) / 0.9);
  border-color: hsl(var(--destructive) / 0.9);
}

.av-btn--link {
  background: transparent;
  color: hsl(var(--primary));
  border-color: transparent;
  padding: 0;
  height: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.av-btn--link:hover:not(:disabled) {
  color: hsl(var(--primary) / 0.8);
}

/* Loading spinner inside button */
.av-btn__spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: av-spin 0.6s linear infinite;
}
@keyframes av-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   INPUT  — .av-input
   ============================================================ */
.av-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.av-field--full-width {
  width: 100%;
}

.av-input__label {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  line-height: 1.25;
}
.av-input__label-required {
  color: hsl(var(--destructive));
  margin-left: 2px;
}
.av-input__hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.25;
}
.av-input__error {
  font-size: 0.75rem;
  color: hsl(var(--destructive));
  line-height: 1.25;
}

.av-input__wrapper {
  display: flex;
  align-items: stretch;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  overflow: hidden;
}
.av-input__wrapper:focus-within {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.15);
}
.av-input__wrapper--error {
  border-color: hsl(var(--destructive));
}
.av-input__wrapper--error:focus-within {
  border-color: hsl(var(--destructive));
  box-shadow: 0 0 0 2px hsl(var(--destructive) / 0.2);
}
.av-input__wrapper--disabled {
  opacity: 0.5;
  pointer-events: none;
  background: hsl(var(--muted) / 0.4);
}

/* Sizes (applied to the wrapper height) */
.av-input__wrapper--sm {
  height: 2rem;
}
.av-input__wrapper--md {
  height: 2.125rem;
}
.av-input__wrapper--lg {
  height: 2.625rem;
}

.av-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 0.75rem;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}
.av-input::placeholder {
  color: hsl(var(--muted-foreground));
}
.av-input__wrapper--sm .av-input {
  font-size: 0.8125rem;
  padding: 0 0.625rem;
}
.av-input__wrapper--lg .av-input {
  font-size: 0.9375rem;
  padding: 0 0.875rem;
}

.av-input__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}
.av-input__icon--left {
  padding-left: 0.75rem;
  padding-right: 0;
}
.av-input__icon--right {
  padding-left: 0;
  padding-right: 0.75rem;
}

.av-input__addon {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  background: hsl(var(--muted) / 0.4);
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  flex-shrink: 0;
}
.av-input__addon--left {
  border-right: 1px solid hsl(var(--border));
}
.av-input__addon--right {
  border-left: 1px solid hsl(var(--border));
}

/* Textarea — standalone, no wrapper */
.av-textarea {
  display: block;
  width: 100%;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  resize: vertical;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  outline: none;
}
.av-textarea::placeholder {
  color: hsl(var(--muted-foreground));
}
.av-textarea:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.15);
}
.av-textarea--error {
  border-color: hsl(var(--destructive));
}
.av-textarea--error:focus {
  box-shadow: 0 0 0 2px hsl(var(--destructive) / 0.2);
}

/* ============================================================
   SELECT — .av-select
   ============================================================ */
.av-select__wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.av-select__wrapper:focus-within {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.15);
}
.av-select__wrapper--error {
  border-color: hsl(var(--destructive));
}
.av-select__wrapper--error:focus-within {
  box-shadow: 0 0 0 2px hsl(var(--destructive) / 0.2);
}
.av-select__wrapper--sm {
  height: 2rem;
}
.av-select__wrapper--md {
  height: 2.125rem;
}
.av-select__wrapper--lg {
  height: 2.625rem;
}

.av-select {
  flex: 1 1 auto;
  height: 100%;
  padding: 0 2rem 0 0.75rem;
  background: transparent;
  border: none;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  cursor: pointer;
  width: 100%;
}
.av-select__chevron {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: hsl(var(--muted-foreground));
  width: 1rem;
  height: 1rem;
}

/* ============================================================
   CHECKBOX — .av-checkbox
   ============================================================ */
.av-checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.av-checkbox--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.av-checkbox__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.av-checkbox__box {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.25rem;
  color: transparent;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
  margin-top: 0.125rem; /* visual align with first line of label */
}
.av-checkbox__input:checked + .av-checkbox__box,
.av-checkbox__input:indeterminate + .av-checkbox__box {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.av-checkbox__input:focus-visible + .av-checkbox__box {
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}
.av-checkbox__check,
.av-checkbox__indeterminate {
  width: 0.75rem;
  height: 0.75rem;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
  display: none;
}
.av-checkbox__input:checked + .av-checkbox__box .av-checkbox__check {
  display: block;
}
.av-checkbox__input:indeterminate
  + .av-checkbox__box
  .av-checkbox__indeterminate {
  display: block;
}

.av-checkbox__label {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  line-height: 1.25rem;
}
.av-checkbox__hint {
  display: block;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 2px;
}

/* ============================================================
   SWITCH — .av-switch
   ============================================================ */
.av-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.av-switch--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.av-switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.av-switch__track {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.av-switch__track--sm {
  width: 1.75rem;
  height: 1rem;
}
.av-switch__track--md {
  width: 2.25rem;
  height: 1.25rem;
}

.av-switch__thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  background: hsl(var(--card));
  border-radius: 9999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}
.av-switch__track--sm .av-switch__thumb {
  width: 0.75rem;
  height: 0.75rem;
}
.av-switch__track--md .av-switch__thumb {
  width: 1rem;
  height: 1rem;
}

.av-switch__input:checked + .av-switch__track {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}
.av-switch__input:checked + .av-switch__track--sm .av-switch__thumb {
  transform: translate(0.75rem, -50%);
}
.av-switch__input:checked + .av-switch__track--md .av-switch__thumb {
  transform: translate(1rem, -50%);
}
.av-switch__input:focus-visible + .av-switch__track {
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}

.av-switch__label {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

/* ============================================================
   ALERT — .av-alert
   ============================================================ */
.av-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px solid;
  border-radius: var(--av-radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.4;
}
.av-alert__icon {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 1px;
}
.av-alert__body {
  flex: 1 1 auto;
  min-width: 0;
}
.av-alert__title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}
.av-alert__message {
  color: inherit;
  opacity: 0.92;
}
.av-alert__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.av-alert__dismiss {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  padding: 0.125rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  border-radius: 0.25rem;
  line-height: 0;
}
.av-alert__dismiss:hover {
  opacity: 1;
}
.av-alert__dismiss:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Variants — inline hex to avoid Tailwind color-palette dep */
.av-alert--info {
  background: #eff6ff; /* blue-50 */
  border-color: #bfdbfe; /* blue-200 */
  color: #1d4ed8; /* blue-700 */
}
.av-alert--info .av-alert__icon {
  color: #2563eb;
} /* blue-600 */

.av-alert--success {
  background: #ecfdf5; /* emerald-50 */
  border-color: #a7f3d0; /* emerald-200 */
  color: #047857; /* emerald-700 */
}
.av-alert--success .av-alert__icon {
  color: #059669;
} /* emerald-600 */

.av-alert--warning {
  background: #fffbeb; /* amber-50 */
  border-color: #fde68a; /* amber-200 */
  color: #b45309; /* amber-700 */
}
.av-alert--warning .av-alert__icon {
  color: #d97706;
} /* amber-600 */

.av-alert--error {
  background: #fef2f2; /* red-50 */
  border-color: #fecaca; /* red-200 */
  color: #b91c1c; /* red-700 */
}
.av-alert--error .av-alert__icon {
  color: #dc2626;
} /* red-600 */

/* Dark-mode overrides */
.dark .av-alert--info,
[data-theme="dark"] .av-alert--info {
  background: rgba(30, 58, 138, 0.25); /* blue-900/40 */
  border-color: rgba(30, 64, 175, 0.6); /* blue-800/60 */
  color: #93c5fd; /* blue-300 */
}
.dark .av-alert--success,
[data-theme="dark"] .av-alert--success {
  background: rgba(6, 78, 59, 0.25);
  border-color: rgba(6, 95, 70, 0.6);
  color: #6ee7b7;
}
.dark .av-alert--warning,
[data-theme="dark"] .av-alert--warning {
  background: rgba(120, 53, 15, 0.25);
  border-color: rgba(146, 64, 14, 0.6);
  color: #fcd34d;
}
.dark .av-alert--error,
[data-theme="dark"] .av-alert--error {
  background: rgba(127, 29, 29, 0.25);
  border-color: rgba(153, 27, 27, 0.6);
  color: #fca5a5;
}

/* ============================================================
   BADGE — .av-badge
   ============================================================ */
.av-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 9999px;
}
.av-badge__dot {
  display: inline-block;
  border-radius: 9999px;
  background: currentColor;
}

/* Sizes */
.av-badge--sm {
  padding: 0 0.375rem;
  font-size: 0.625rem;
  gap: 0.25rem;
}
.av-badge--sm .av-badge__dot {
  width: 0.375rem;
  height: 0.375rem;
}
.av-badge--md {
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
}
.av-badge--md .av-badge__dot {
  width: 0.5rem;
  height: 0.5rem;
}
.av-badge--lg {
  padding: 0.25rem 0.625rem;
  font-size: 0.875rem;
}
.av-badge--lg .av-badge__dot {
  width: 0.5rem;
  height: 0.5rem;
}

/* Variants */
.av-badge--default {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.2);
}
.av-badge--secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.av-badge--outline {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.av-badge--neutral {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border-color: hsl(var(--border));
}
.av-badge--custom {
  background: var(--av-badge-bg, hsl(var(--primary) / 0.1));
  color: var(--av-badge-color, hsl(var(--primary)));
  border-color: var(--av-badge-border, hsl(var(--primary) / 0.2));
}
.av-badge--custom .av-badge__dot {
  background: var(--av-badge-color, currentColor);
}
.av-badge--success {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
.av-badge--warning {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}
.av-badge--gold {
  background: hsl(44 51% 54% / 0.16);
  color: hsl(44 51% 54%);
  border-color: hsl(44 51% 54% / 0.34);
}
.av-badge--danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.av-badge--custom-hex {
  --av-badge-bg: hsl(var(--primary) / 0.1);
  --av-badge-color: hsl(var(--primary));
  --av-badge-border: hsl(var(--primary) / 0.2);
  background: var(--av-badge-bg);
  color: var(--av-badge-color);
  border-color: var(--av-badge-border);
}
.av-badge--info {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}

.dark .av-badge--success,
[data-theme="dark"] .av-badge--success {
  background: rgba(6, 78, 59, 0.4);
  color: #6ee7b7;
  border-color: rgba(6, 95, 70, 0.6);
}
.dark .av-badge--warning,
[data-theme="dark"] .av-badge--warning {
  background: rgba(120, 53, 15, 0.4);
  color: #fcd34d;
  border-color: rgba(146, 64, 14, 0.6);
}
.dark .av-badge--danger,
[data-theme="dark"] .av-badge--danger {
  background: rgba(127, 29, 29, 0.4);
  color: #fca5a5;
  border-color: rgba(153, 27, 27, 0.6);
}
.dark .av-badge--info,
[data-theme="dark"] .av-badge--info {
  background: rgba(12, 74, 110, 0.4);
  color: #7dd3fc;
  border-color: rgba(7, 89, 133, 0.6);
}

/* ============================================================
   CARD — .av-card
   ============================================================ */
.av-card {
  border-radius: calc(var(--av-radius) + 4px); /* rounded-xl */
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
}
.av-card--top-accent {
  border-top: 3px solid hsl(var(--primary));
}
.av-card--top-accent-primary {
  border-top-color: hsl(224 60% 22%);
}
.av-card--top-accent-gold {
  border-top-color: hsl(44 51% 54%);
}
.av-card--elevated {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.av-card--outline {
  background: transparent;
}
.av-card--ghost {
  background: hsl(var(--muted) / 0.4);
  border-color: transparent;
}
.av-card--interactive {
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
  cursor: pointer;
}
.av-card--interactive:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* Padding */
.av-card--pad-none {
  padding: 0;
}
.av-card--pad-sm {
  padding: 0.75rem;
}
.av-card--pad-md {
  padding: 1rem;
}
.av-card--pad-lg {
  padding: 1.5rem;
}

/* Card sub-parts */
.av-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.av-card__header-main {
  min-width: 0;
  flex: 1 1 auto;
}
.av-card__header-action {
  flex-shrink: 0;
}
.av-card__title {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  color: hsl(var(--card-foreground));
  margin: 0;
}
.av-card__description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0;
  line-height: 1.4;
}
.av-card__footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   DIVIDER — .av-divider
   ============================================================ */
.av-divider {
  border: 0;
  display: block;
  height: 1px;
  width: 100%;
  background: hsl(var(--border));
  margin: 0;
}
.av-divider--dashed {
  background: transparent;
  border-top: 1px dashed hsl(var(--border));
  height: 0;
}
.av-divider--vertical {
  display: inline-block;
  align-self: stretch;
  width: 1px;
  height: auto;
  background: hsl(var(--border));
}
.av-divider--vertical.av-divider--dashed {
  background: transparent;
  border-left: 1px dashed hsl(var(--border));
  border-top: 0;
  width: 0;
}

.av-divider--with-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  background: none;
  height: auto;
}
.av-divider--with-label::before,
.av-divider--with-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: hsl(var(--border));
}
.av-divider--with-label.av-divider--dashed::before,
.av-divider--with-label.av-divider--dashed::after {
  background: transparent;
  border-top: 1px dashed hsl(var(--border));
  height: 0;
}
/**
 * AV Design System — Wave 2 (Navigation)
 * Source: @sgeo/ui-kit v4.0 .tsx → handwritten CSS
 *
 * Components:
 *   .av-page-header   — title + optional subtitle + icon + actions + editorial underline
 *   .av-breadcrumbs   — standard path breadcrumbs (new — not in .tsx source)
 *   .av-pill-tabs     — tablist с pill-табами (+ icon/count)
 *   .av-segmented     — segmented control, variants: cards | compact
 *   .av-lang-switcher — compact language switcher (KZ / RU / EN by default)
 */

/* ============================================================
   PAGE HEADER — .av-page-header
   ============================================================ */
.av-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.av-page-header__main {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
  flex: 1 1 auto;
}
.av-page-header__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: calc(var(--av-radius) + 4px);
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / 0.15);
}
.av-page-header__icon > svg,
.av-page-header__icon > img {
  width: 1.375rem;
  height: 1.375rem;
}
.av-page-header__text {
  min-width: 0;
}
.av-page-header__title {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: hsl(var(--foreground));
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.av-page-header__subtitle {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0;
  line-height: 1.55;
  max-width: 42rem;
}
.av-page-header__underline {
  display: flex;
  height: 1px;
  width: 100%;
  margin-top: 1rem;
}
.av-page-header__underline-accent {
  display: inline-block;
  height: 1px;
  width: 3rem;
  background: hsl(var(--primary));
}
.av-page-header__underline-rest {
  flex: 1 1 auto;
  background: hsl(var(--border));
}
.av-page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (max-width: 540px) {
  .av-page-header__title {
    white-space: normal;
    font-size: 1.375rem;
  }
}

/* ============================================================
   BREADCRUMBS — .av-breadcrumbs
   ============================================================ */
.av-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  list-style: none;
  padding: 0;
  margin: 0;
}
.av-breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.av-breadcrumbs__link {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease;
}
.av-breadcrumbs__link:hover,
.av-breadcrumbs__link:focus-visible {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.av-breadcrumbs__current {
  color: hsl(var(--foreground));
  font-weight: 500;
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.av-breadcrumbs__separator {
  color: hsl(var(--border));
  user-select: none;
  line-height: 1;
  font-size: 0.75rem;
}
.av-breadcrumbs__home {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.av-breadcrumbs__home > svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* ============================================================
   PILL TABS — .av-pill-tabs
   ============================================================ */
.av-pill-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 9px;
  padding: 3px;
}
.av-pill-tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: hsl(var(--muted-foreground));
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
  text-decoration: none;
}
.av-pill-tabs__tab:hover:not([aria-disabled="true"]):not(
    [aria-selected="true"]
  ) {
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.5);
}
.av-pill-tabs__tab:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--card)),
    0 0 0 4px hsl(var(--ring));
}
.av-pill-tabs__tab[aria-selected="true"] {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.av-pill-tabs__tab[aria-disabled="true"],
.av-pill-tabs__tab:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Sizes */
.av-pill-tabs--sm .av-pill-tabs__tab {
  padding: 4px 10px;
  font-size: 11px;
}
.av-pill-tabs--md .av-pill-tabs__tab {
  padding: 6px 12px;
  font-size: 12px;
}

/* Count badge inside tab */
.av-pill-tabs__count {
  display: inline-block;
  min-width: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  line-height: 1;
}
.av-pill-tabs__tab[aria-selected="true"] .av-pill-tabs__count {
  background: hsl(var(--primary-foreground) / 0.2);
  color: hsl(var(--primary-foreground));
}

/* ============================================================
   SEGMENTED CONTROL — .av-segmented
   ============================================================ */
.av-segmented {
  display: block;
}
.av-segmented__label {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

/* COMPACT variant — pill group inside muted background */
.av-segmented--compact .av-segmented__group {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: hsl(var(--muted));
  border-radius: calc(var(--av-radius) + 2px);
}
.av-segmented--compact.av-segmented--full-width .av-segmented__group {
  width: 100%;
}
.av-segmented--compact .av-segmented__opt {
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  padding: 6px 12px;
  border-radius: var(--av-radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}
.av-segmented--compact
  .av-segmented__opt:hover:not([aria-checked="true"]):not(:disabled) {
  color: hsl(var(--foreground));
}
.av-segmented--compact .av-segmented__opt:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}
.av-segmented--compact .av-segmented__opt[aria-checked="true"] {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.av-segmented--compact .av-segmented__opt-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* CARDS variant — grid of bordered cards with description */
.av-segmented--cards .av-segmented__group {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.av-segmented--cards .av-segmented__opt {
  text-align: left;
  padding: 0.75rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
  font-family: var(--font-sans);
  color: hsl(var(--foreground));
}
.av-segmented--cards
  .av-segmented__opt:hover:not([aria-checked="true"]):not(:disabled) {
  border-color: hsl(var(--foreground) / 0.3);
  background: hsl(var(--muted) / 0.4);
}
.av-segmented--cards .av-segmented__opt:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px hsl(var(--background)),
    0 0 0 4px hsl(var(--ring));
}
.av-segmented--cards .av-segmented__opt[aria-checked="true"] {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / 0.3);
}
.av-segmented--cards .av-segmented__opt-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
}
.av-segmented--cards .av-segmented__opt-description {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}

.av-segmented__opt:disabled,
.av-segmented__opt[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   LANGUAGE SWITCHER — .av-lang-switcher
   ============================================================ */
.av-lang-switcher {
  display: inline-flex;
  align-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius);
  overflow: hidden;
  background: hsl(var(--card));
}
.av-lang-switcher__btn {
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
  text-decoration: none;
  line-height: 1.25rem;
}
.av-lang-switcher__btn + .av-lang-switcher__btn {
  border-left: 1px solid hsl(var(--border));
}
.av-lang-switcher__btn:hover:not([aria-pressed="true"]) {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.av-lang-switcher__btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px hsl(var(--ring));
}
.av-lang-switcher__btn[aria-pressed="true"] {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
/* ==========================================================================
   AV Design System — Wave 3: Cards & Metrics
   AccentCard, MiniMetric, ScoreBar, DataTable, Sparkline
   ========================================================================== */

/* --- AccentCard ----------------------------------------------------------- */
.av-accent-card {
  position: relative;
  border-radius: var(--radius, 0.75rem);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  padding: 1.25rem;
  transition:
    box-shadow 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}
.av-accent-card--clickable {
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.av-accent-card--clickable:hover {
  border-color: hsl(var(--border) / 0.8);
  transform: translateY(-1px);
}
.av-accent-card--clickable:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--ring));
}

/* Accent top-line */
.av-accent-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: transparent;
  pointer-events: none;
}
.av-accent-card--primary::before {
  background: hsl(var(--primary));
}
.av-accent-card--green::before {
  background: hsl(142 71% 45%);
}
.av-accent-card--amber::before {
  background: hsl(38 92% 50%);
}
.av-accent-card--red::before {
  background: hsl(0 84% 60%);
}
.av-accent-card--neutral::before {
  background: hsl(var(--muted-foreground) / 0.5);
}
.av-accent-card--none::before {
  display: none;
}

/* Optional glow */
.av-accent-card--glow.av-accent-card--primary {
  box-shadow:
    0 0 0 1px hsl(var(--primary) / 0.15),
    0 8px 24px -8px hsl(var(--primary) / 0.25);
}
.av-accent-card--glow.av-accent-card--green {
  box-shadow:
    0 0 0 1px hsl(142 71% 45% / 0.15),
    0 8px 24px -8px hsl(142 71% 45% / 0.25);
}
.av-accent-card--glow.av-accent-card--amber {
  box-shadow:
    0 0 0 1px hsl(38 92% 50% / 0.15),
    0 8px 24px -8px hsl(38 92% 50% / 0.25);
}
.av-accent-card--glow.av-accent-card--red {
  box-shadow:
    0 0 0 1px hsl(0 84% 60% / 0.15),
    0 8px 24px -8px hsl(0 84% 60% / 0.25);
}

/* --- MiniMetric ----------------------------------------------------------- */
.av-metric {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.av-metric__header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: hsl(var(--muted-foreground));
}
.av-metric__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.av-metric__label {
  font-size: 0.6875rem; /* 11px */
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
}
.av-metric__body {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.av-metric--block .av-metric__body {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}
.av-metric__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: hsl(var(--foreground));
}
.av-metric__affix {
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  font-size: 0.85em;
}

/* Sizes */
.av-metric--compact .av-metric__value {
  font-size: 1.125rem;
}
.av-metric--compact .av-metric__icon svg {
  width: 14px;
  height: 14px;
}
.av-metric--default .av-metric__value {
  font-size: 1.5rem;
}
.av-metric--default .av-metric__icon svg {
  width: 16px;
  height: 16px;
}
.av-metric--hero .av-metric__value {
  font-size: 2.25rem;
}
.av-metric--hero .av-metric__icon svg {
  width: 20px;
  height: 20px;
}

/* Invert (dark surface) */
.av-metric--invert .av-metric__header {
  color: hsl(var(--primary-foreground) / 0.7);
}
.av-metric--invert .av-metric__value {
  color: hsl(var(--primary-foreground));
}
.av-metric--invert .av-metric__affix {
  color: hsl(var(--primary-foreground) / 0.8);
}

/* Delta chip */
.av-metric__delta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.av-metric__delta--up {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 71% 35%);
}
.av-metric__delta--down {
  background: hsl(0 84% 60% / 0.12);
  color: hsl(0 72% 45%);
}
.av-metric__delta--zero {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.av-metric__delta-label {
  font-weight: 500;
  opacity: 0.8;
}

/* --- ScoreBar ------------------------------------------------------------- */
.av-score-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}
.av-score-bar__label {
  min-width: 5rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}
.av-score-bar__track {
  position: relative;
  flex: 1;
  height: 0.5rem;
  background: hsl(var(--muted));
  border-radius: 9999px;
  overflow: hidden;
}
.av-score-bar__progress,
.av-score-bar__fill {
  height: 100%;
  border-radius: 9999px;
  background: hsl(var(--primary));
  transform-origin: left center;
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  border: 0;
  appearance: none;
  color: transparent;
}
.av-score-bar__progress {
  margin: 0;
  padding: 0;
}

.av-score-bar__progress::-webkit-progress-bar {
  background: transparent;
}

.av-score-bar__progress::-webkit-progress-value,
.av-score-bar__progress::-moz-progress-bar {
  border-radius: 9999px;
  background: hsl(var(--primary));
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
.av-score-bar__progress--green::-webkit-progress-value,
.av-score-bar__progress--green::-moz-progress-bar {
  background: hsl(142 71% 45%);
}
.av-score-bar__progress--amber::-webkit-progress-value,
.av-score-bar__progress--amber::-moz-progress-bar {
  background: hsl(38 92% 50%);
}
.av-score-bar__progress--red::-webkit-progress-value,
.av-score-bar__progress--red::-moz-progress-bar {
  background: hsl(0 84% 60%);
}
.av-score-bar__value {
  min-width: 2rem;
  text-align: right;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--foreground));
  flex-shrink: 0;
}

/* --- DataTable ------------------------------------------------------------ */
.av-data-table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius, 0.75rem);
  background: hsl(var(--card));
}
.av-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}
.av-data-table__head {
  background: hsl(var(--muted) / 0.4);
  border-bottom: 1px solid hsl(var(--border));
}
.av-data-table__th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.av-data-table__th--right {
  text-align: right;
}
.av-data-table__th--center {
  text-align: center;
}
.av-data-table--compact .av-data-table__th,
.av-data-table--compact .av-data-table__td {
  padding: 0.5rem 0.75rem;
}
.av-data-table__row {
  border-bottom: 1px solid hsl(var(--border));
  transition: background 120ms ease;
}
.av-data-table__row:last-child {
  border-bottom: 0;
}
.av-data-table__row--clickable {
  cursor: pointer;
}
.av-data-table__row--clickable:hover {
  background: hsl(var(--muted) / 0.3);
}
.av-data-table__row--clickable:focus-visible {
  outline: none;
  background: hsl(var(--muted) / 0.4);
  box-shadow: inset 0 0 0 2px hsl(var(--ring));
}
.av-data-table__td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}
.av-data-table__td--right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.av-data-table__td--center {
  text-align: center;
}
.av-data-table__td--muted {
  color: hsl(var(--muted-foreground));
}
.av-data-table__empty {
  padding: 2rem 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

@media (max-width: 640px) {
  .av-data-table__th--hide-mobile,
  .av-data-table__td--hide-mobile {
    display: none;
  }
}

/* --- Sparkline ------------------------------------------------------------ */
.av-sparkline {
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
}
.av-sparkline--empty {
  width: var(--av-sparkline-width, 80px);
  height: var(--av-sparkline-height, 24px);
}
.av-sparkline svg {
  display: block;
  overflow: visible;
}
.av-sparkline__path {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.av-sparkline__area {
  fill-opacity: 0.12;
  stroke: none;
}
.av-sparkline__last-point {
  /* stroke set inline from --background token via macro */
}
/* ==========================================================================
   AV Design System — Wave 4: Editorial patterns
   ArticleHero, ArticleBody (.av-prose), PersonCard, FeedCard
   + helpers: KeyFactsBox, ExpertQuote, Callout, AIBadge
   ========================================================================== */

/* --- ArticleHero ---------------------------------------------------------- */
.av-article-hero {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem 0 1rem;
}
.av-article-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--primary));
}
.av-article-hero__eyebrow a {
  color: inherit;
  text-decoration: none;
}
.av-article-hero__eyebrow a:hover {
  text-decoration: underline;
}
.av-article-hero__title {
  font-family: var(--font-serif, Georgia, "Times New Roman", serif);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
  margin: 0;
}
.av-article-hero__deck {
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
  font-weight: 400;
  margin: 0;
  max-width: 65ch;
}
.av-article-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  padding-top: 0.5rem;
  border-top: 1px solid hsl(var(--border));
  margin-top: 0.25rem;
}
.av-article-hero__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.av-article-hero__author {
  color: hsl(var(--foreground));
  font-weight: 600;
  text-decoration: none;
}
.av-article-hero__author:hover {
  text-decoration: underline;
}
.av-article-hero__figure {
  margin: 1.5rem 0 0.25rem;
  border-radius: var(--radius, 0.75rem);
  overflow: hidden;
}
.av-article-hero__figure img {
  display: block;
  width: 100%;
  height: auto;
}
.av-article-hero__caption {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* --- AI disclosure badge -------------------------------------------------- */
.av-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / 0.2);
}
.av-ai-badge svg {
  width: 12px;
  height: 12px;
}

/* --- ArticleBody / .av-prose ---------------------------------------------- */
.av-prose {
  --prose-width: 68ch;
  max-width: var(--prose-width);
  font-family: var(--font-serif, Georgia, "Times New Roman", serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: hsl(var(--foreground));
}
.av-prose > * + * {
  margin-top: 1.15em;
}
.av-prose h2 {
  font-family: var(--font-sans, system-ui);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.3;
  margin-top: 2em;
  color: hsl(var(--foreground));
}
.av-prose h3 {
  font-family: var(--font-sans, system-ui);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.35;
  margin-top: 1.75em;
  color: hsl(var(--foreground));
}
.av-prose p {
  margin: 0;
}
.av-prose a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.av-prose a:hover {
  text-decoration-thickness: 2px;
}
.av-prose ul,
.av-prose ol {
  padding-left: 1.5em;
}
.av-prose li + li {
  margin-top: 0.35em;
}
.av-prose blockquote {
  border-left: 3px solid hsl(var(--primary));
  padding: 0.25em 0 0.25em 1.25em;
  color: hsl(var(--foreground));
  font-style: italic;
  margin: 1.5em 0;
}
.av-prose img,
.av-prose figure {
  border-radius: 0.5rem;
  max-width: 100%;
  height: auto;
}
.av-prose hr {
  border: 0;
  border-top: 1px solid hsl(var(--border));
  margin: 2em 0;
}
.av-prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: hsl(var(--muted));
  padding: 0.125em 0.35em;
  border-radius: 0.25rem;
}

/* --- KeyFactsBox ---------------------------------------------------------- */
.av-key-facts {
  background: hsl(var(--muted) / 0.4);
  border-left: 4px solid hsl(var(--primary));
  border-radius: 0.5rem;
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
  font-family: var(--font-sans, system-ui);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.av-key-facts__title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--primary));
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.av-key-facts__list {
  margin: 0;
  padding-left: 1.25rem;
}
.av-key-facts__list li {
  margin: 0.4em 0;
}
.av-key-facts__list li::marker {
  color: hsl(var(--primary));
}

/* --- ExpertQuote ---------------------------------------------------------- */
.av-expert-quote {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border-left: 4px solid hsl(var(--primary));
  background: linear-gradient(
    to right,
    hsl(var(--primary) / 0.04),
    transparent
  );
  border-radius: 0 0.5rem 0.5rem 0;
  font-family: var(--font-sans, system-ui);
}
.av-expert-quote__text {
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.125rem;
  line-height: 1.55;
  font-style: italic;
  color: hsl(var(--foreground));
  margin: 0 0 0.75rem;
  position: relative;
}
.av-expert-quote__text::before {
  content: "\201C";
  position: absolute;
  left: -0.5em;
  top: -0.15em;
  font-size: 2.5em;
  color: hsl(var(--primary) / 0.35);
  line-height: 1;
  font-family: Georgia, serif;
}
.av-expert-quote__attribution {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}
.av-expert-quote__avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  object-fit: cover;
  flex-shrink: 0;
  background: hsl(var(--muted));
}
.av-expert-quote__author {
  font-weight: 600;
  color: hsl(var(--foreground));
}
.av-expert-quote__role {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

/* --- Callout -------------------------------------------------------------- */
.av-callout {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  display: flex;
  gap: 0.75rem;
  font-family: var(--font-sans, system-ui);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.av-callout__icon {
  flex-shrink: 0;
  margin-top: 0.15em;
  color: hsl(var(--foreground));
}
.av-callout__body > * + * {
  margin-top: 0.5em;
}
.av-callout__title {
  font-weight: 700;
  color: hsl(var(--foreground));
}
.av-callout--info {
  background: hsl(var(--primary) / 0.06);
  border-color: hsl(var(--primary) / 0.25);
}
.av-callout--warn {
  background: hsl(38 92% 50% / 0.08);
  border-color: hsl(38 92% 50% / 0.35);
}
.av-callout--danger {
  background: hsl(0 84% 60% / 0.07);
  border-color: hsl(0 84% 60% / 0.3);
}
.av-callout--success {
  background: hsl(142 71% 45% / 0.07);
  border-color: hsl(142 71% 45% / 0.3);
}
.av-callout--info .av-callout__icon {
  color: hsl(var(--primary));
}
.av-callout--warn .av-callout__icon {
  color: hsl(38 92% 50%);
}
.av-callout--danger .av-callout__icon {
  color: hsl(0 84% 60%);
}
.av-callout--success .av-callout__icon {
  color: hsl(142 71% 45%);
}

/* --- PersonCard ----------------------------------------------------------- */
.av-person-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius, 0.75rem);
  background: hsl(var(--card));
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
}
.av-person-card--clickable {
  cursor: pointer;
}
.av-person-card--clickable:hover {
  border-color: hsl(var(--primary) / 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px -6px hsl(var(--foreground) / 0.08);
}
.av-person-card__avatar {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  object-fit: cover;
  flex-shrink: 0;
  background: hsl(var(--muted));
  border: 2px solid hsl(var(--border));
}
.av-person-card__body {
  flex: 1;
  min-width: 0;
}
.av-person-card__name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  color: hsl(var(--foreground));
  margin: 0 0 0.125rem;
}
.av-person-card__role {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin: 0 0 0.375rem;
  line-height: 1.3;
}
.av-person-card__bio {
  font-size: 0.875rem;
  line-height: 1.45;
  color: hsl(var(--foreground) / 0.85);
  margin: 0.5rem 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.av-person-card__stats {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}
.av-person-card__stat strong {
  color: hsl(var(--foreground));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Compact layout (sidebar) */
.av-person-card--compact {
  padding: 0.625rem 0.75rem;
  gap: 0.625rem;
}
.av-person-card--compact .av-person-card__avatar {
  width: 40px;
  height: 40px;
}
.av-person-card--compact .av-person-card__name {
  font-size: 0.875rem;
}
.av-person-card--compact .av-person-card__role {
  font-size: 0.75rem;
}
.av-person-card--compact .av-person-card__bio,
.av-person-card--compact .av-person-card__stats {
  display: none;
}

/* Hero layout (top of person page) */
.av-person-card--hero {
  padding: 1.5rem;
  gap: 1.5rem;
}
.av-person-card--hero .av-person-card__avatar {
  width: 96px;
  height: 96px;
}
.av-person-card--hero .av-person-card__name {
  font-size: 1.5rem;
}
.av-person-card--hero .av-person-card__role {
  font-size: 0.9375rem;
}

/* --- FeedCard ------------------------------------------------------------- */
.av-feed-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius, 0.75rem);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  text-decoration: none;
  color: inherit;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}
.av-feed-card:hover {
  transform: translateY(-2px);
  border-color: hsl(var(--primary) / 0.35);
  box-shadow: 0 8px 24px -10px hsl(var(--foreground) / 0.12);
}
.av-feed-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: hsl(var(--muted));
}
.av-feed-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}
.av-feed-card:hover .av-feed-card__media img {
  transform: scale(1.03);
}
.av-feed-card__category {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.av-feed-card__category--plain {
  position: static;
  display: inline-block;
  align-self: flex-start;
  margin-bottom: 0.25rem;
  background: transparent;
  color: hsl(var(--muted-foreground));
  padding: 0;
  border-radius: 0;
}
.av-feed-card__date {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: hsl(0 0% 0% / 0.55);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  backdrop-filter: blur(4px);
}
.av-feed-card__body {
  padding: 0.875rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1;
}
.av-feed-card__title {
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: hsl(var(--foreground));
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.3em * 3);
}
.av-feed-card__deck {
  font-size: 0.875rem;
  line-height: 1.45;
  color: hsl(var(--muted-foreground));
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.av-feed-card__meta {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Horizontal variant (compact list) */
.av-feed-card--horizontal {
  flex-direction: row;
  align-items: stretch;
}
.av-feed-card--horizontal .av-feed-card__media {
  aspect-ratio: 1 / 1;
  width: 120px;
  flex-shrink: 0;
}
.av-feed-card--horizontal .av-feed-card__body {
  padding: 0.75rem 1rem;
}

/* Size: small */
.av-feed-card--sm .av-feed-card__title {
  font-size: 0.9375rem;
  -webkit-line-clamp: 2;
  min-height: calc(1.3em * 2);
}
.av-feed-card--sm .av-feed-card__body {
  padding: 0.75rem 0.875rem;
}

/* --- Home editorial patterns -------------------------------------------- */
.av-home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: stretch;
  min-height: 420px;
}

.av-home-hero {
  position: relative;
  display: flex;
  min-height: 420px;
  overflow: hidden;
  border-radius: var(--av-radius, 0.5rem);
  background: hsl(var(--primary));
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  isolation: isolate;
}

.av-home-hero:hover .av-home-hero__media img {
  transform: scale(1.025);
}

.av-home-hero__media {
  position: absolute;
  inset: 0;
  background: hsl(var(--primary));
}

.av-home-hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 360ms ease;
}

.av-home-hero__shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      180deg,
      hsl(224 60% 12% / 0.1) 0%,
      hsl(224 60% 12% / 0.82) 100%
    ),
    linear-gradient(90deg, hsl(224 60% 12% / 0.62) 0%, transparent 56%);
}

.av-home-hero__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  max-width: 760px;
  padding: 1.75rem;
}

.av-home-hero__badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.625rem;
  border-radius: 0.25rem;
  background: hsl(var(--primary) / 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.av-home-hero__badge--live {
  background: hsl(var(--destructive));
}

.av-home-hero__dot,
.av-home-feed__pulse {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
  animation: avHomePulse 1.5s ease-in-out infinite;
}

.av-home-hero__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: 0;
  color: #fff;
}

.av-home-hero__deck {
  margin: 0 0 0.625rem;
  max-width: 64ch;
  font-size: 0.92rem;
  line-height: 1.5;
  color: hsl(0 0% 100% / 0.86);
}

.av-home-hero__date {
  font-size: 0.75rem;
  color: hsl(0 0% 100% / 0.68);
}

.av-home-feed {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius, 0.5rem);
  background: hsl(var(--card));
  box-shadow: var(--shadow-sm);
}

.av-home-feed__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.av-home-feed__pulse {
  color: hsl(var(--destructive));
}

.av-home-feed__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.av-home-feed__item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border) / 0.72);
  color: hsl(var(--foreground));
  text-decoration: none;
  transition:
    background-color 140ms ease,
    color 140ms ease;
  min-height: 4.5rem;
}

.av-home-feed__item:hover {
  background: hsl(var(--muted) / 0.55);
}

.av-home-feed__time {
  min-width: 2.4rem;
  flex-shrink: 0;
  color: hsl(var(--chart-3));
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.av-home-feed__text {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.86rem;
  line-height: 1.4;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.av-home-feed__more {
  display: block;
  padding: 0.85rem 1rem;
  border-top: 1px solid hsl(var(--border));
  color: hsl(var(--primary));
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 140ms ease;
}

.av-home-feed__more:hover {
  background: hsl(var(--muted) / 0.55);
}

.av-home-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.av-home-section-header__main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.625rem;
  min-width: 0;
}

.av-home-section-header__title {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  margin: 0;
  color: hsl(var(--foreground));
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0;
}

.av-home-section-header__icon {
  display: inline-flex;
  color: hsl(var(--chart-3));
  flex-shrink: 0;
}

.av-home-section-header__label {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.72rem;
  font-weight: 700;
}

.av-home-section-header__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 2rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.375rem;
  background: hsl(var(--card));
  color: hsl(var(--primary));
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.av-home-section-header__action:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.av-cta-tile {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex: 1 1 0;
  min-width: 0;
  padding: 0.875rem 1.125rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--av-radius, 0.5rem);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.av-cta-tile:hover {
  border-color: hsl(var(--primary) / 0.45);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.av-cta-tile__icon,
.av-cta-tile__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.av-cta-tile__icon {
  color: hsl(var(--primary));
}

.av-cta-tile__body {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.av-cta-tile__title {
  color: hsl(var(--primary));
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
}

.av-cta-tile__description {
  color: hsl(var(--muted-foreground));
  font-size: 0.74rem;
  line-height: 1.35;
}

.av-cta-tile__arrow {
  width: 1.25rem;
  height: 1.25rem;
  margin-left: auto;
  color: hsl(var(--primary) / 0.55);
}

.av-cta-tile__arrow svg {
  width: 1rem;
  height: 1rem;
}

.av-cta-tile--gold .av-cta-tile__icon,
.av-cta-tile--gold .av-cta-tile__title {
  color: hsl(var(--chart-3));
}

@keyframes avHomePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@media (max-width: 1024px) {
  .av-home-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    min-height: 380px;
  }

  .av-home-hero {
    min-height: 380px;
  }
}

@media (max-width: 768px) {
  .av-home-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .av-home-hero {
    min-height: 300px;
  }

  .av-home-hero__content {
    padding: 1.25rem;
  }

  .av-home-hero__title {
    font-size: 1.35rem;
  }

  .av-home-feed {
    max-height: 320px;
  }

  .av-home-section-header {
    align-items: flex-start;
    margin-bottom: 0.625rem;
  }

  .av-home-section-header__title {
    font-size: 1rem;
  }
}

@media (max-width: 560px) {
  .av-home-layout {
    gap: 0;
  }

  .av-home-hero {
    min-height: 220px;
    border-radius: var(--av-radius, 0.5rem) var(--av-radius, 0.5rem) 0 0;
  }

  .av-home-hero__content {
    padding: 0.875rem 1rem;
  }

  .av-home-hero__title {
    font-size: 1.08rem;
  }

  .av-home-hero__deck {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .av-home-feed {
    border-radius: 0 0 var(--av-radius, 0.5rem) var(--av-radius, 0.5rem);
  }

  .av-home-feed__header,
  .av-home-feed__more {
    padding: 0.55rem 0.875rem;
    font-size: 0.72rem;
  }

  .av-home-feed__item {
    padding: 0.55rem 0.875rem;
    gap: 0.625rem;
  }

  .av-home-feed__text {
    font-size: 0.8rem;
  }

  .av-home-section-header {
    flex-direction: column;
  }

  .av-home-section-header__action {
    align-self: flex-start;
    min-height: 1.8rem;
    font-size: 0.72rem;
  }

  .av-cta-tile {
    padding: 0.7rem 0.85rem;
  }

  .av-cta-tile__title {
    font-size: 0.82rem;
  }

  .av-cta-tile__description {
    font-size: 0.68rem;
  }
}
/* ==========================================================================
   AV Design System — Wave 5: Admin UI primitives
   DataTable (enhanced), InlineEditableTable, DetailDrawer, KanbanBoard, Toast, Dialog
   ========================================================================== */

/* --- DataTable (enhanced, extends Wave 3 .av-data-table) ----------------- */
.av-data-table__th--sortable {
  cursor: pointer;
  user-select: none;
}
.av-data-table__sort-link {
  color: inherit;
  text-decoration: none;
}
.av-data-table__th--sortable button {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}
.av-data-table__th--sortable:hover {
  color: hsl(var(--foreground));
}
.av-data-table__sort-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  opacity: 0.35;
  transition:
    opacity 120ms,
    transform 160ms;
}
.av-data-table__th--sort-asc .av-data-table__sort-icon {
  opacity: 1;
}
.av-data-table__th--sort-desc .av-data-table__sort-icon {
  opacity: 1;
  transform: rotate(180deg);
}

/* Selection checkbox col */
.av-data-table__th--select,
.av-data-table__td--select {
  width: 36px;
  padding-left: 0.5rem;
  padding-right: 0;
}
.av-data-table__row--selected {
  background: hsl(var(--primary) / 0.06);
}
.av-data-table__row--selected:hover {
  background: hsl(var(--primary) / 0.1) !important;
}

/* Toolbar above table */
.av-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid hsl(var(--border));
  border-bottom: 0;
  border-top-left-radius: var(--radius, 0.75rem);
  border-top-right-radius: var(--radius, 0.75rem);
  background: hsl(var(--card));
}
.av-table-toolbar + .av-data-table-wrap {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: 0;
}
.av-table-toolbar__search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.av-table-toolbar__search-field {
  position: relative;
}

.av-table-toolbar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

.av-table-toolbar__search-input {
  padding-left: 2rem;
  width: 100%;
}
.av-table-toolbar__spacer {
  flex: 1;
}
.av-table-toolbar__selection {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}
.av-table-toolbar__selection strong {
  color: hsl(var(--foreground));
  font-weight: 700;
}

/* Pagination */
.av-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border: 1px solid hsl(var(--border));
  border-top: 0;
  border-bottom-left-radius: var(--radius, 0.75rem);
  border-bottom-right-radius: var(--radius, 0.75rem);
  background: hsl(var(--card));
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}
.av-pagination__nav {
  display: inline-flex;
  gap: 0.25rem;
}
.av-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.375rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.av-pagination__btn:hover {
  background: hsl(var(--muted));
}
.av-pagination__btn--active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.av-pagination__btn--disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- InlineEditableTable -------------------------------------------------- */
.av-editable-cell {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 28px;
}
.av-editable-cell__display {
  cursor: text;
  padding: 0.125rem 0.35rem;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  min-width: 40px;
}
.av-editable-cell__display:hover {
  background: hsl(var(--muted) / 0.6);
  border-color: hsl(var(--border));
}
.av-editable-cell__display:focus-visible {
  outline: none;
  background: hsl(var(--muted) / 0.8);
  border-color: hsl(var(--ring));
}
.av-editable-cell__form {
  display: none;
  gap: 0.25rem;
  align-items: center;
  width: 100%;
}
.av-editable-cell[data-editing="true"] .av-editable-cell__display {
  display: none;
}
.av-editable-cell[data-editing="true"] .av-editable-cell__form {
  display: inline-flex;
}
.av-editable-cell__input {
  flex: 1;
  min-width: 80px;
  padding: 0.125rem 0.35rem;
  border: 1px solid hsl(var(--primary) / 0.5);
  border-radius: 0.25rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
}
.av-editable-cell__input:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2);
}
.av-editable-cell__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  border-radius: 0.25rem;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
}
.av-editable-cell__btn:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.av-editable-cell__btn--save {
  color: hsl(142 71% 35%);
}
.av-editable-cell__btn--cancel {
  color: hsl(0 72% 45%);
}

/* --- DetailDrawer --------------------------------------------------------- */
.av-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 60;
  backdrop-filter: blur(1.5px);
}
.av-drawer-backdrop[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.av-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  max-width: 100vw;
  background: hsl(var(--background));
  border-left: 1px solid hsl(var(--border));
  box-shadow: -8px 0 24px -8px hsl(var(--foreground) / 0.12);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 61;
  display: flex;
  flex-direction: column;
}
.av-drawer[data-open="true"] {
  transform: translateX(0);
}
.av-drawer--left {
  right: auto;
  left: 0;
  border-left: 0;
  border-right: 1px solid hsl(var(--border));
  transform: translateX(-100%);
}
.av-drawer--wide {
  width: min(720px, 100vw);
}
.av-drawer__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.av-drawer__title {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin: 0;
}
.av-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 0.375rem;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
}
.av-drawer__close:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.av-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}
.av-drawer__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.3);
}

/* --- KanbanBoard ---------------------------------------------------------- */
.av-kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  align-items: stretch;
}
.av-kanban__column {
  flex: 0 0 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: hsl(var(--muted) / 0.4);
  border-radius: var(--radius, 0.75rem);
  border: 1px solid hsl(var(--border));
  max-height: 100%;
}
.av-kanban__column-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.av-kanban__column-title {
  flex: 1;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: hsl(var(--foreground));
}
.av-kanban__column-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0.0625rem 0.375rem;
  border-radius: 9999px;
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-weight: 600;
}
.av-kanban__column--accent-primary .av-kanban__column-header {
  box-shadow: inset 3px 0 0 hsl(var(--primary));
}
.av-kanban__column--accent-green .av-kanban__column-header {
  box-shadow: inset 3px 0 0 hsl(142 71% 45%);
}
.av-kanban__column--accent-amber .av-kanban__column-header {
  box-shadow: inset 3px 0 0 hsl(38 92% 50%);
}
.av-kanban__column--accent-red .av-kanban__column-header {
  box-shadow: inset 3px 0 0 hsl(0 84% 60%);
}
.av-kanban__body {
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 60px;
}
.av-kanban__card {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  padding: 0.75rem 0.875rem;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px hsl(var(--foreground) / 0.04);
  cursor: grab;
  transition:
    transform 120ms,
    box-shadow 120ms,
    border-color 120ms;
  text-decoration: none;
  color: inherit;
  display: block;
}
.av-kanban__card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px -4px hsl(var(--foreground) / 0.1);
  border-color: hsl(var(--primary) / 0.4);
}
.av-kanban__card:active {
  cursor: grabbing;
}
.av-kanban__card-title {
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.25rem;
  color: hsl(var(--foreground));
}

.av-kanban__eyebrow {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.av-kanban__deck {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
  line-height: 1.4;
}
.av-kanban__card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.375rem;
}
.av-kanban__card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.av-kanban__card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}
.av-kanban__tag {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 0.25rem;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.av-kanban__column-footer {
  padding: 0.5rem;
  border-top: 1px solid hsl(var(--border));
}
.av-kanban__add {
  display: block;
  width: 100%;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  background: transparent;
  border: 1px dashed hsl(var(--border));
  border-radius: 0.375rem;
  cursor: pointer;
  text-decoration: none;
}
.av-kanban__add:hover {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

/* --- Toast ---------------------------------------------------------------- */
.av-toast-region {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.av-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  min-width: 260px;
  max-width: 420px;
  padding: 0.75rem 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-left: 4px solid hsl(var(--primary));
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px -8px hsl(var(--foreground) / 0.2);
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  animation: av-toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.av-toast[data-closing="true"] {
  animation: av-toast-out 180ms ease forwards;
}
.av-toast--success {
  border-left-color: hsl(142 71% 45%);
}
.av-toast--warn {
  border-left-color: hsl(38 92% 50%);
}
.av-toast--error {
  border-left-color: hsl(0 84% 60%);
}
.av-toast__icon {
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.av-toast__body {
  flex: 1;
  line-height: 1.4;
}
.av-toast__title {
  font-weight: 700;
  margin-bottom: 0.125rem;
}
.av-toast__close {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  padding: 0.125rem;
  border-radius: 0.25rem;
  line-height: 0;
}
.av-toast__close:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

@keyframes av-toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes av-toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* --- Dialog --------------------------------------------------------------- */
dialog.av-dialog {
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius, 0.75rem);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  max-width: min(520px, calc(100vw - 2rem));
  width: 100%;
  box-shadow: 0 20px 48px -12px hsl(var(--foreground) / 0.3);
  overflow: hidden;
}
dialog.av-dialog::backdrop {
  background: hsl(0 0% 0% / 0.5);
  backdrop-filter: blur(2px);
}
.av-dialog--wide {
  max-width: min(720px, calc(100vw - 2rem));
}
.av-dialog__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.av-dialog__title {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: hsl(var(--foreground));
}
.av-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 0.375rem;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
}
.av-dialog__close:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.av-dialog__body {
  padding: 1.25rem;
}
.av-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.3);
}
