@layer tokens, reset, base, components, utilities, responsive;

@layer tokens {
:root {
    --sp-error: var(--sp-danger);
    --sp-info: var(--sp-accent);
    --sp-color-primary: var(--sp-accent);
    --sp-color-success: var(--sp-success);
    --sp-color-info: light-dark(oklch(0.62 0.18 260), oklch(0.70 0.14 250));
    --sp-color-warning: var(--sp-warning);
    --sp-accent-blue: light-dark(oklch(0.62 0.18 260), oklch(0.70 0.14 250));
    --sp-accent-surface: light-dark(
      color-mix(in oklch, var(--sp-accent) 6%, var(--sp-bg-surface)),
      color-mix(in oklch, var(--sp-accent) 8%, var(--sp-bg-surface))
    );

    --sp-bg-input: light-dark(oklch(1.0 0 0), oklch(0.19 0.01 47));
    --sp-bg-primary: var(--sp-bg-surface);
    --sp-bg-secondary: var(--sp-bg-surface-raised);
    --sp-bg-tertiary: light-dark(oklch(0.96 0.005 70), oklch(0.23 0.01 48));
    --sp-bg-warning: light-dark(
      color-mix(in oklch, var(--sp-warning) 10%, var(--sp-bg-surface)),
      color-mix(in oklch, var(--sp-warning) 12%, var(--sp-bg-surface))
    );
    --sp-surface-1: var(--sp-bg-surface);
    --sp-surface-2: var(--sp-bg-surface-raised);

    --sp-border: var(--sp-border-default);
    --sp-border-color: var(--sp-border-default);
    --sp-border-hover: var(--sp-border-strong);
    --sp-border-primary: light-dark(
      color-mix(in oklch, var(--sp-accent) 30%, var(--sp-border-default)),
      color-mix(in oklch, var(--sp-accent) 25%, var(--sp-border-default))
    );

    --sp-text-muted: var(--sp-text-tertiary);

    --sp-font-mono: "SF Mono", "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;

    --sp-z-modal-backdrop: 1400;
    --sp-z-tooltip: 3000;

    --sp-color-primary: var(--sp-accent);
    --sp-color-success: var(--sp-success);
    --sp-color-border: var(--sp-border-default);
    --sp-color-surface: var(--sp-bg-surface);
    --sp-color-text: var(--sp-text-primary);
    --sp-color-text-secondary: var(--sp-text-secondary);
    --sp-font-size-sm: var(--sp-text-sm);
    --sp-font-size-md: var(--sp-text-base);
    --sp-font-size-xl: var(--sp-text-xl);
    --sp-space-xs: var(--sp-space-1);
    --sp-space-sm: var(--sp-space-2);
    --sp-space-md: var(--sp-space-4);
    --sp-space-lg: var(--sp-space-6);
    --sp-space-xl: var(--sp-space-8);
}
}

@layer tokens {
:root {
    color-scheme: light dark;


    --sp-primitive-brand-50:  oklch(0.96 0.03 60);
    --sp-primitive-brand-100: oklch(0.93 0.06 58);
    --sp-primitive-brand-200: oklch(0.85 0.12 55);
    --sp-primitive-brand-300: oklch(0.78 0.15 53);
    --sp-primitive-brand-400: oklch(0.75 0.16 52);
    --sp-primitive-brand-500: oklch(0.72 0.17 52);
    --sp-primitive-brand-600: oklch(0.67 0.18 50);
    --sp-primitive-brand-700: oklch(0.57 0.16 48);
    --sp-primitive-brand-800: oklch(0.47 0.13 47);
    --sp-primitive-brand-900: oklch(0.37 0.09 46);
    --sp-primitive-brand-950: oklch(0.25 0.05 45);
    --sp-primitive-warm-50:  oklch(0.98 0.004 70);
    --sp-primitive-warm-100: oklch(0.96 0.005 70);
    --sp-primitive-warm-200: oklch(0.92 0.008 65);
    --sp-primitive-warm-300: oklch(0.86 0.010 60);
    --sp-primitive-warm-400: oklch(0.70 0.01 70);
    --sp-primitive-warm-500: oklch(0.53 0.01 65);
    --sp-primitive-warm-600: oklch(0.41 0.01 60);
    --sp-primitive-warm-700: oklch(0.34 0.01 55);
    --sp-primitive-warm-800: oklch(0.24 0.01 50);
    --sp-primitive-warm-900: oklch(0.20 0.01 50);
    --sp-primitive-warm-950: oklch(0.13 0.01 45);
    --sp-primitive-white: oklch(1.00 0 0);
    --sp-primitive-black: oklch(0 0 0);

    /* Must match the @font-face families actually shipped in core/fonts.css. */
    --sp-font-family: "OpenSans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --sp-font-heading: "Inter", system-ui, sans-serif;
    --sp-text-xs: 0.6875rem;
    --sp-text-sm: 0.8125rem;
    --sp-text-base: 0.9375rem;
    --sp-text-md: 1rem;
    --sp-text-lg: 1.25rem;
    --sp-text-xl: 1.5rem;
    --sp-text-2xl: 2rem;

    --sp-primary-50:  light-dark(var(--sp-primitive-brand-50),  var(--sp-primitive-brand-950));
    --sp-primary-100: light-dark(var(--sp-primitive-brand-100), oklch(0.31 0.07 46));
    --sp-primary-200: light-dark(var(--sp-primitive-brand-200), oklch(0.42 0.11 47));
    --sp-primary-300: light-dark(var(--sp-primitive-brand-300), oklch(0.52 0.14 48));
    --sp-primary-400: light-dark(var(--sp-primitive-brand-400), var(--sp-primitive-brand-600));
    --sp-primary-500: light-dark(var(--sp-primitive-brand-500), var(--sp-primitive-brand-500));
    --sp-primary-600: light-dark(var(--sp-primitive-brand-600), var(--sp-primitive-brand-400));
    --sp-primary-700: light-dark(var(--sp-primitive-brand-700), var(--sp-primitive-brand-300));
    --sp-primary-800: light-dark(var(--sp-primitive-brand-800), var(--sp-primitive-brand-200));
    --sp-primary-900: light-dark(var(--sp-primitive-brand-900), var(--sp-primitive-brand-100));
    --sp-primary-950: light-dark(var(--sp-primitive-brand-950), var(--sp-primitive-brand-50));

    --sp-warm-50:  light-dark(var(--sp-primitive-warm-50),  var(--sp-primitive-warm-950));
    --sp-warm-100: light-dark(var(--sp-primitive-warm-100), var(--sp-primitive-warm-900));
    --sp-warm-200: light-dark(var(--sp-primitive-warm-200), var(--sp-primitive-warm-800));
    --sp-warm-300: light-dark(var(--sp-primitive-warm-300), var(--sp-primitive-warm-700));
    --sp-warm-400: light-dark(var(--sp-primitive-warm-400), var(--sp-primitive-warm-600));
    --sp-warm-500: light-dark(var(--sp-primitive-warm-500), var(--sp-primitive-warm-500));
    --sp-warm-600: light-dark(var(--sp-primitive-warm-600), var(--sp-primitive-warm-400));
    --sp-warm-700: light-dark(var(--sp-primitive-warm-700), var(--sp-primitive-warm-300));
    --sp-warm-800: light-dark(var(--sp-primitive-warm-800), var(--sp-primitive-warm-200));
    --sp-warm-900: light-dark(var(--sp-primitive-warm-900), var(--sp-primitive-warm-100));
    --sp-warm-950: light-dark(var(--sp-primitive-warm-950), var(--sp-primitive-warm-50));

    --sp-bg-base:            light-dark(oklch(0.96 0.004 70), oklch(0.16 0.01 45));
    --sp-bg-canvas:          light-dark(oklch(0.98 0.003 70), oklch(0.18 0.01 45));
    --sp-bg-surface:         light-dark(oklch(1.0 0 0), oklch(0.21 0.01 48));
    --sp-bg-surface-raised:  light-dark(oklch(1.0 0 0), oklch(0.24 0.01 48));
    --sp-bg-surface-overlay: light-dark(oklch(0.98 0.003 70), oklch(0.28 0.01 48));

    --sp-border-subtle:  light-dark(oklch(0.20 0.01 50 / 0.08), oklch(1.00 0 0 / 0.06));
    --sp-border-default: light-dark(oklch(0.20 0.01 50 / 0.12), oklch(1.00 0 0 / 0.10));
    --sp-border-strong:  light-dark(oklch(0.20 0.01 50 / 0.20), oklch(1.00 0 0 / 0.16));

    --sp-text-primary:   light-dark(var(--sp-primitive-warm-900), var(--sp-primitive-warm-50));
    --sp-text-secondary: light-dark(var(--sp-primitive-warm-600), var(--sp-primitive-warm-300));
    --sp-text-tertiary:  light-dark(var(--sp-primitive-warm-500), var(--sp-primitive-warm-400));
    --sp-text-disabled:  light-dark(var(--sp-primitive-warm-400), var(--sp-primitive-warm-600));
    --sp-text-on-accent: var(--sp-primitive-white);
    --sp-text-on-dark:   var(--sp-primitive-white);

    --sp-interactive:    light-dark(var(--sp-primitive-brand-600), var(--sp-primitive-brand-400));
    --sp-accent:         light-dark(var(--sp-primitive-brand-600), var(--sp-primitive-brand-400));
    --sp-accent-hover:   light-dark(var(--sp-primitive-brand-700), var(--sp-primitive-brand-300));
    --sp-accent-dim:     light-dark(
      color-mix(in oklch, var(--sp-accent) 10%, transparent),
      color-mix(in oklch, var(--sp-accent) 15%, transparent)
    );
    --sp-accent-strong:  light-dark(
      color-mix(in oklch, var(--sp-accent) 18%, transparent),
      color-mix(in oklch, var(--sp-accent) 25%, transparent)
    );

    --sp-sidebar-bg: light-dark(var(--sp-primitive-warm-50), oklch(0.22 0.03 50));
    --sp-sidebar-border: light-dark(var(--sp-primitive-warm-200), oklch(0.30 0.02 50));
    --sp-sidebar-text: light-dark(var(--sp-primitive-warm-600), oklch(1.00 0 0 / 0.75));
    --sp-sidebar-text-muted: light-dark(var(--sp-primitive-warm-500), oklch(1.00 0 0 / 0.45));
    --sp-sidebar-text-hover: light-dark(var(--sp-primitive-warm-900), var(--sp-primitive-white));
    --sp-sidebar-hover-bg: light-dark(var(--sp-primitive-warm-100), oklch(1.00 0 0 / 0.06));
    --sp-sidebar-active-bg: light-dark(oklch(0.95 0.015 55), color-mix(in oklch, var(--sp-primitive-brand-500) 15%, transparent));
    --sp-sidebar-active-color: light-dark(var(--sp-primitive-brand-600), var(--sp-primitive-brand-400));

    --sp-success: light-dark(oklch(0.69 0.17 165), oklch(0.78 0.16 165));
    --sp-success-dim: light-dark(
      color-mix(in oklch, var(--sp-success) 14%, transparent),
      color-mix(in oklch, var(--sp-success) 16%, transparent)
    );
    --sp-success-strong: light-dark(
      color-mix(in oklch, var(--sp-success) 22%, transparent),
      color-mix(in oklch, var(--sp-success) 25%, transparent)
    );

    --sp-warning: light-dark(oklch(0.76 0.16 75), oklch(0.83 0.16 85));
    --sp-warning-dim: light-dark(
      color-mix(in oklch, var(--sp-warning) 14%, transparent),
      color-mix(in oklch, var(--sp-warning) 16%, transparent)
    );
    --sp-warning-strong: light-dark(
      color-mix(in oklch, var(--sp-warning) 22%, transparent),
      color-mix(in oklch, var(--sp-warning) 25%, transparent)
    );

    --sp-danger: light-dark(oklch(0.63 0.21 25), oklch(0.70 0.17 20));
    --sp-danger-dim: light-dark(
      color-mix(in oklch, var(--sp-danger) 12%, transparent),
      color-mix(in oklch, var(--sp-danger) 14%, transparent)
    );
    --sp-danger-strong: light-dark(
      color-mix(in oklch, var(--sp-danger) 18%, transparent),
      color-mix(in oklch, var(--sp-danger) 20%, transparent)
    );

    --sp-section-dashboard: light-dark(var(--sp-primitive-brand-600), var(--sp-primitive-brand-400));
    --sp-section-users:     light-dark(oklch(0.55 0.22 295), oklch(0.68 0.16 295));
    --sp-section-plugins:   light-dark(oklch(0.62 0.18 260), oklch(0.70 0.14 250));
    --sp-section-skills:    light-dark(oklch(0.69 0.17 165), oklch(0.78 0.16 165));
    --sp-section-export:    light-dark(oklch(0.76 0.16 75), oklch(0.83 0.16 85));
    --sp-section-audit:     light-dark(oklch(0.63 0.21 25), oklch(0.70 0.17 20));
    --sp-section-dashboard-dim: light-dark(
      color-mix(in oklch, var(--sp-section-dashboard) 14%, transparent),
      color-mix(in oklch, var(--sp-section-dashboard) 16%, transparent)
    );
    --sp-section-users-dim: light-dark(
      color-mix(in oklch, var(--sp-section-users) 14%, transparent),
      color-mix(in oklch, var(--sp-section-users) 16%, transparent)
    );
    --sp-section-plugins-dim: light-dark(
      color-mix(in oklch, var(--sp-section-plugins) 14%, transparent),
      color-mix(in oklch, var(--sp-section-plugins) 16%, transparent)
    );
    --sp-section-skills-dim: light-dark(
      color-mix(in oklch, var(--sp-section-skills) 14%, transparent),
      color-mix(in oklch, var(--sp-section-skills) 16%, transparent)
    );
    --sp-section-export-dim: light-dark(
      color-mix(in oklch, var(--sp-section-export) 14%, transparent),
      color-mix(in oklch, var(--sp-section-export) 16%, transparent)
    );
    --sp-section-audit-dim: light-dark(
      color-mix(in oklch, var(--sp-section-audit) 14%, transparent),
      color-mix(in oklch, var(--sp-section-audit) 16%, transparent)
    );

    --sp-chart-purple:  var(--sp-section-users);
    --sp-chart-green:   var(--sp-section-skills);
    --sp-chart-blue:    var(--sp-section-plugins);
    --sp-chart-indigo:  light-dark(oklch(0.55 0.20 275), oklch(0.65 0.18 275));
    --sp-chart-red:     var(--sp-danger);
}
}

@layer tokens {
:root {
    --sp-chart-purple: light-dark(oklch(0.55 0.22 295), oklch(0.68 0.16 295));
    --sp-chart-blue:   light-dark(oklch(0.62 0.18 260), oklch(0.70 0.14 250));
    --sp-chart-green:  light-dark(oklch(0.69 0.17 165), oklch(0.78 0.16 165));
    --sp-chart-amber:  light-dark(oklch(0.76 0.16 75), oklch(0.83 0.16 85));
    --sp-chart-red:    light-dark(oklch(0.63 0.21 25), oklch(0.70 0.17 20));
    --sp-chart-cyan:   light-dark(oklch(0.72 0.12 200), oklch(0.82 0.11 200));

    --sp-progress-green-from: light-dark(oklch(0.69 0.17 165), oklch(0.78 0.16 165));
    --sp-progress-green-to:   light-dark(oklch(0.78 0.16 165), oklch(0.85 0.13 160));
    --sp-progress-amber-from: light-dark(oklch(0.76 0.16 75), oklch(0.83 0.16 85));
    --sp-progress-amber-to:   light-dark(oklch(0.83 0.16 85), oklch(0.88 0.13 85));
    --sp-progress-red-from:   light-dark(oklch(0.63 0.21 25), oklch(0.70 0.17 20));
    --sp-progress-red-to:     light-dark(oklch(0.70 0.17 20), oklch(0.78 0.10 20));

    --sp-nav-label-1: light-dark(oklch(0.55 0.16 52), oklch(0.75 0.16 52));
    --sp-nav-label-2: light-dark(oklch(0.55 0.12 300), oklch(0.80 0.12 300));
    --sp-nav-label-3: light-dark(oklch(0.52 0.10 255), oklch(0.78 0.10 255));
    --sp-nav-label-4: light-dark(oklch(0.55 0.13 160), oklch(0.85 0.13 160));
    --sp-nav-label-5: light-dark(oklch(0.58 0.13 85), oklch(0.88 0.13 85));
    --sp-nav-badge-text: light-dark(oklch(0.55 0.10 20), oklch(0.78 0.10 20));

    --sp-feed-purple: light-dark(oklch(0.55 0.22 295), oklch(0.68 0.16 295));
    --sp-feed-cyan:   light-dark(oklch(0.72 0.12 200), oklch(0.82 0.11 200));
    --sp-feed-indigo: light-dark(oklch(0.57 0.18 280), oklch(0.65 0.14 280));
    --sp-feed-gold:   light-dark(oklch(0.76 0.16 75), oklch(0.83 0.16 85));
    --sp-badge-purple: light-dark(oklch(0.68 0.16 295), oklch(0.68 0.16 295));
    --sp-badge-purple-dim: light-dark(
      color-mix(in oklch, oklch(0.68 0.16 295) 15%, transparent),
      color-mix(in oklch, oklch(0.68 0.16 295) 18%, transparent)
    );

    --sp-rank-tier-1-color: light-dark(oklch(0.72 0.03 250), oklch(0.82 0.03 250));
    --sp-rank-tier-1-bg:    light-dark(oklch(0.50 0.03 250), oklch(0.55 0.03 250));
    --sp-rank-tier-2-color: light-dark(oklch(0.70 0.14 250), oklch(0.78 0.10 255));
    --sp-rank-tier-2-bg:    light-dark(oklch(0.55 0.14 250), oklch(0.50 0.14 255));
    --sp-rank-tier-3-color: light-dark(oklch(0.78 0.16 165), oklch(0.85 0.13 160));
    --sp-rank-tier-3-bg:    light-dark(oklch(0.58 0.16 165), oklch(0.55 0.16 160));
    --sp-rank-tier-4-color: light-dark(oklch(0.68 0.16 295), oklch(0.80 0.12 300));
    --sp-rank-tier-4-bg:    light-dark(oklch(0.55 0.16 295), oklch(0.50 0.16 300));
    --sp-rank-tier-5-color: light-dark(oklch(0.76 0.16 75), oklch(0.88 0.13 85));
    --sp-rank-tier-5-bg:    light-dark(oklch(0.56 0.16 75), oklch(0.52 0.16 85));
    --sp-rank-tier-6-color: light-dark(oklch(0.65 0.20 345), oklch(0.78 0.11 350));
    --sp-rank-tier-6-bg:    light-dark(oklch(0.52 0.18 345), oklch(0.48 0.18 350));
    --sp-rank-tier-7-color: light-dark(oklch(0.70 0.18 45), oklch(0.80 0.12 60));
    --sp-rank-tier-7-bg:    light-dark(oklch(0.55 0.18 45), oklch(0.52 0.18 60));
    --sp-rank-tier-8-color: light-dark(oklch(0.55 0.22 295), oklch(0.68 0.16 295));
    --sp-rank-tier-8-bg:    light-dark(oklch(0.45 0.20 295), oklch(0.42 0.20 295));
    --sp-rank-tier-9-color: light-dark(oklch(0.72 0.12 200), oklch(0.82 0.11 200));
    --sp-rank-tier-9-bg:    light-dark(oklch(0.52 0.14 200), oklch(0.48 0.14 200));
    --sp-rank-tier-10-color: light-dark(oklch(0.82 0.17 95), oklch(0.88 0.15 95));
    --sp-rank-tier-10-bg:    light-dark(oklch(0.58 0.17 95), oklch(0.55 0.17 95));

    --sp-rank-1-color: var(--sp-rank-tier-1-color);
    --sp-rank-2-color: var(--sp-rank-tier-1-color);
    --sp-rank-3-color: var(--sp-rank-tier-2-color);
    --sp-rank-4-color: var(--sp-rank-tier-2-color);
    --sp-rank-5-color: var(--sp-rank-tier-3-color);
    --sp-rank-6-color: var(--sp-rank-tier-3-color);
    --sp-rank-7-color: var(--sp-rank-tier-4-color);
    --sp-rank-8-color: var(--sp-rank-tier-5-color);
    --sp-rank-9-color: var(--sp-rank-tier-6-color);
    --sp-rank-10-color: var(--sp-rank-tier-7-color);
    --sp-rank-1-bg: var(--sp-rank-tier-1-bg);
    --sp-rank-2-bg: var(--sp-rank-tier-1-bg);
    --sp-rank-3-bg: var(--sp-rank-tier-2-bg);
    --sp-rank-4-bg: var(--sp-rank-tier-2-bg);
    --sp-rank-5-bg: var(--sp-rank-tier-3-bg);
    --sp-rank-6-bg: var(--sp-rank-tier-3-bg);
    --sp-rank-7-bg: var(--sp-rank-tier-4-bg);
    --sp-rank-8-bg: var(--sp-rank-tier-5-bg);
    --sp-rank-9-bg: var(--sp-rank-tier-6-bg);
    --sp-rank-10-bg: var(--sp-rank-tier-7-bg);
    --sp-rank-1-ladder-bg: var(--sp-rank-tier-1-bg);
    --sp-rank-3-ladder-bg: var(--sp-rank-tier-2-bg);
    --sp-rank-5-ladder-bg: var(--sp-rank-tier-3-bg);
    --sp-rank-7-ladder-bg: var(--sp-rank-tier-4-bg);
    --sp-rank-10-ladder-bg: var(--sp-rank-tier-7-bg);

    --sp-rarity-epic-bg: light-dark(
      color-mix(in oklch, oklch(0.60 0.20 295) 15%, transparent),
      color-mix(in oklch, oklch(0.60 0.20 295) 18%, transparent)
    );
    --sp-rarity-epic-fg: light-dark(oklch(0.65 0.20 295), oklch(0.70 0.20 295));

    --sp-bg-surface-alt: light-dark(oklch(0.96 0.006 68), oklch(0.22 0.01 47));
    --sp-badge-accent-bg: light-dark(
      color-mix(in oklch, var(--sp-accent) 8%, var(--sp-bg-surface)),
      color-mix(in oklch, var(--sp-accent) 12%, var(--sp-bg-surface))
    );
    --sp-badge-accent-fg: light-dark(oklch(0.50 0.12 48), oklch(0.75 0.14 52));
    --sp-badge-warning-bg: light-dark(
      color-mix(in oklch, var(--sp-warning) 8%, var(--sp-bg-surface)),
      color-mix(in oklch, var(--sp-warning) 12%, var(--sp-bg-surface))
    );
    --sp-badge-warning-fg: light-dark(oklch(0.52 0.10 80), oklch(0.75 0.12 80));
    --sp-badge-danger-bg: light-dark(
      color-mix(in oklch, var(--sp-danger) 8%, var(--sp-bg-surface)),
      color-mix(in oklch, var(--sp-danger) 10%, var(--sp-bg-surface))
    );
    --sp-badge-danger-fg: light-dark(oklch(0.48 0.12 20), oklch(0.72 0.12 20));
}
}

@layer tokens {
:root {
    --sp-radius-xs: 0.25rem;
    --sp-radius-sm: 0.375rem;
    --sp-radius-md: 0.625rem;
    --sp-radius-lg: 0.875rem;
    --sp-radius-xl: 1.25rem;
    --sp-radius-full: 9999px;
    --sp-radius-card: 1rem;
    --sp-radius-card-inner: 0.625rem;
    --sp-radius-widget: 1.25rem;
    --sp-radius-button: 0.5rem;
    --sp-radius-badge: 0.375rem;
    --sp-radius-brand-tr: 0.375rem;
    --sp-radius-card-brand: var(--sp-corners-md);
    --sp-radius-card-inner-brand: var(--sp-corners-inner-md);
    --sp-radius-widget-brand: 1.25rem 0.375rem 1.25rem 1.25rem;

    --sp-space-1:  0.25rem;
    --sp-space-2:  0.5rem;
    --sp-space-3:  0.75rem;
    --sp-space-4:  1rem;
    --sp-space-5:  1.25rem;
    --sp-space-6:  1.5rem;
    --sp-space-7:  1.75rem;
    --sp-space-8:  2rem;
    --sp-space-10: 2.5rem;
    --sp-space-12: 3rem;

    --sp-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --sp-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --sp-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --sp-duration-micro: 80ms;
    --sp-duration-fast: 150ms;
    --sp-duration-normal: 200ms;
    --sp-duration-slow: 350ms;

    --sp-z-sticky: 1;
    --sp-z-sticky-header: 3;
    --sp-z-sidebar: 900;
    --sp-z-sidebar-drawer: 950;
    --sp-z-dropdown: 1000;
    --sp-z-panel: 1100;
    --sp-z-modal: 1500;
    --sp-z-lightbox: 2000;
    --sp-z-toast: 2500;

    --sp-overlay-light:  light-dark(oklch(0.20 0.01 50 / 0.3), oklch(0 0 0 / 0.5));
    --sp-overlay-medium: light-dark(oklch(0.20 0.01 50 / 0.5), oklch(0 0 0 / 0.65));
    --sp-overlay-heavy:  light-dark(oklch(0.20 0.01 50 / 0.7), oklch(0 0 0 / 0.8));
}
}

@layer tokens {
:root {

  --sp-primitive-brand-50:  oklch(0.96 0.03 60);
  --sp-primitive-brand-100: oklch(0.93 0.06 58);
  --sp-primitive-brand-200: oklch(0.86 0.11 55);
  --sp-primitive-brand-300: oklch(0.78 0.14 52);
  --sp-primitive-brand-400: oklch(0.73 0.16 50);
  --sp-primitive-brand-500: oklch(0.70 0.17 50);
  --sp-primitive-brand-600: oklch(0.65 0.18 48);
  --sp-primitive-brand-700: oklch(0.55 0.15 47);
  --sp-primitive-brand-800: oklch(0.45 0.12 46);
  --sp-primitive-brand-900: oklch(0.35 0.08 45);
  --sp-primitive-brand-950: oklch(0.25 0.05 45);

  --sp-primitive-warm-50:  oklch(0.98 0.003 60);
  --sp-primitive-warm-100: oklch(0.96 0.004 60);
  --sp-primitive-warm-200: oklch(0.92 0.006 58);
  --sp-primitive-warm-300: oklch(0.86 0.008 55);
  --sp-primitive-warm-400: oklch(0.70 0.008 55);
  --sp-primitive-warm-500: oklch(0.53 0.008 55);
  --sp-primitive-warm-600: oklch(0.41 0.008 55);
  --sp-primitive-warm-700: oklch(0.34 0.008 55);
  --sp-primitive-warm-800: oklch(0.24 0.008 55);
  --sp-primitive-warm-900: oklch(0.20 0.008 55);
  --sp-primitive-warm-950: oklch(0.13 0.006 55);

  --sp-primitive-white: oklch(1.00 0 0);
  --sp-primitive-black: oklch(0 0 0);

  --sp-primitive-green-500:  oklch(0.72 0.19 155);
  --sp-primitive-green-400:  oklch(0.78 0.16 165);
  --sp-primitive-green-300:  oklch(0.80 0.18 155);
  --sp-primitive-amber-500:  oklch(0.83 0.16 85);
  --sp-primitive-amber-400:  oklch(0.76 0.16 75);
  --sp-primitive-red-500:    oklch(0.63 0.21 25);
  --sp-primitive-red-400:    oklch(0.70 0.17 20);
  --sp-primitive-blue-500:   oklch(0.62 0.18 260);
  --sp-primitive-blue-400:   oklch(0.70 0.14 250);

  --sp-primitive-accent-blue:        oklch(0.70 0.14 250);
  --sp-primitive-accent-blue-light:  oklch(0.78 0.10 255);
  --sp-primitive-accent-purple:      oklch(0.68 0.18 300);
  --sp-primitive-accent-purple-light: oklch(0.80 0.12 300);
  --sp-primitive-accent-green:       oklch(0.80 0.18 155);
  --sp-primitive-accent-green-light: oklch(0.88 0.14 155);
  --sp-primitive-accent-pink:        oklch(0.70 0.17 350);
  --sp-primitive-accent-pink-light:  oklch(0.80 0.12 350);
  --sp-primitive-accent-cyan:        oklch(0.79 0.13 200);
  --sp-primitive-accent-cyan-light:  oklch(0.87 0.10 200);

  --sp-text-xs:   clamp(0.7rem, 0.66rem + 0.2vw, 0.75rem);
  --sp-text-sm:   clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --sp-text-base: clamp(0.875rem, 0.82rem + 0.28vw, 0.9375rem);
  --sp-text-md:   clamp(0.9375rem, 0.87rem + 0.33vw, 1rem);
  --sp-text-lg:   clamp(1rem, 0.93rem + 0.35vw, 1.125rem);
  --sp-text-xl:   clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
  --sp-text-2xl:  clamp(1.4rem, 1.2rem + 1vw, 1.75rem);
  --sp-text-3xl:  clamp(1.75rem, 1.4rem + 1.75vw, 2.5rem);
  --sp-text-4xl:  clamp(2.25rem, 1.6rem + 3.2vw, 4rem);

  --sp-leading-tight:   1.1;
  --sp-leading-snug:    1.25;
  --sp-leading-normal:  1.5;
  --sp-leading-relaxed: 1.625;

  --sp-tracking-tight:  -0.02em;
  --sp-tracking-normal: 0;
  --sp-tracking-wide:   0.05em;

  --sp-font-normal:   400;
  --sp-font-medium:   500;
  --sp-font-semibold: 600;
  --sp-font-bold:     700;

  --sp-space-1:  0.25rem;
  --sp-space-2:  0.5rem;
  --sp-space-3:  0.75rem;
  --sp-space-4:  1rem;
  --sp-space-5:  1.25rem;
  --sp-space-6:  1.5rem;
  --sp-space-8:  2rem;
  --sp-space-10: 2.5rem;
  --sp-space-12: 3rem;
  --sp-space-16: 4rem;
  --sp-space-20: 5rem;
  --sp-space-24: 6rem;
  --sp-space-32: 8rem;

  --sp-radius-xs:   0.125rem;
  --sp-radius-sm:   0.25rem;
  --sp-radius-md:   0.5rem;
  --sp-radius-lg:   0.75rem;
  --sp-radius-xl:   1rem;
  --sp-radius-full: 9999px;

  --sp-corners-sm: 0.375rem 0.125rem 0.375rem 0.375rem;
  --sp-corners-md: 1.125rem 0.375rem 1.125rem 1.125rem;
  --sp-corners-lg: 1.5rem 0.5rem 1.5rem 1.5rem;
  --sp-corners-inner-sm: 0.25rem 0.0625rem 0.25rem 0.25rem;
  --sp-corners-inner-md: 0.625rem 0.25rem 0.625rem 0.625rem;
  --sp-corners-inner-lg: 1.125rem 0.375rem 1.125rem 1.125rem;

  --sp-duration-instant:  50ms;
  --sp-duration-fast:     100ms;
  --sp-duration-normal:   200ms;
  --sp-duration-moderate: 300ms;
  --sp-duration-slow:     400ms;
  --sp-duration-slower:   600ms;

  --sp-ease-default: ease-out;
  --sp-ease-in:      ease-in;
  --sp-ease-out:     ease-out;
  --sp-ease-in-out:  ease-in-out;
  --sp-ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --sp-ease-spring:  cubic-bezier(0.175, 0.885, 0.32, 1.275);

  --sp-shadow-xs: 0 1px 2px oklch(0.30 0.02 50 / 0.06);
  --sp-shadow-sm: 0 1px 3px oklch(0.30 0.02 50 / 0.08), 0 1px 2px oklch(0.30 0.02 50 / 0.06);
  --sp-shadow-md: 0 4px 6px oklch(0.30 0.02 50 / 0.08), 0 2px 4px oklch(0.30 0.02 50 / 0.06);
  --sp-shadow-lg: 0 10px 15px oklch(0.30 0.02 50 / 0.08), 0 4px 6px oklch(0.30 0.02 50 / 0.04);
  --sp-shadow-xl: 0 20px 25px oklch(0.30 0.02 50 / 0.10), 0 8px 10px oklch(0.30 0.02 50 / 0.05);
}
}

@layer tokens {
:root {
    --sp-shadow-xs: 0 1px 2px oklch(0.20 0.01 50 / 0.06);
    --sp-shadow-sm: 0 1px 3px oklch(0.20 0.01 50 / 0.08), 0 1px 2px oklch(0.20 0.01 50 / 0.06);
    --sp-shadow-md: 0 4px 8px oklch(0.20 0.01 50 / 0.09), 0 2px 4px oklch(0.20 0.01 50 / 0.06);
    --sp-shadow-lg: 0 10px 25px oklch(0.20 0.01 50 / 0.12), 0 4px 10px oklch(0.20 0.01 50 / 0.07);
    --sp-shadow-xl: 0 20px 40px oklch(0.20 0.01 50 / 0.14), 0 8px 16px oklch(0.20 0.01 50 / 0.08);
    --sp-shadow-inset-sm: inset 0 1px 2px oklch(0.20 0.01 50 / 0.06);
    --sp-shadow-card: 0 1px 3px oklch(0.20 0.01 50 / 0.09), 0 1px 2px oklch(0.20 0.01 50 / 0.06), 0 0 0 1px oklch(0.20 0.01 50 / 0.05);
    --sp-shadow-card-hover: 0 8px 24px oklch(0.20 0.01 50 / 0.14), 0 2px 6px oklch(0.20 0.01 50 / 0.08), 0 0 0 1px oklch(0.20 0.01 50 / 0.06);
    --sp-shadow-elevated: 0 4px 16px oklch(0.20 0.01 50 / 0.12), 0 2px 6px oklch(0.20 0.01 50 / 0.07), 0 0 1px oklch(0.20 0.01 50 / 0.15);
    --sp-shadow-float: 0 12px 40px oklch(0.20 0.01 50 / 0.16), 0 4px 12px oklch(0.20 0.01 50 / 0.08);
    --sp-shadow-accent-sm: 0 2px 8px color-mix(in oklch, var(--sp-accent) 16%, transparent);
    --sp-shadow-accent-md: 0 4px 16px color-mix(in oklch, var(--sp-accent) 20%, transparent);
    --sp-shadow-inner-glow: inset 0 1px 0 oklch(1.00 0 0 / 0.5);
    --sp-shadow-hero: 0 4px 16px oklch(0.20 0.01 50 / 0.10), 0 2px 4px oklch(0.20 0.01 50 / 0.06), 0 0 0 1px oklch(0.20 0.01 50 / 0.06);
    --sp-shadow-lift: 0 6px 20px oklch(0.20 0.01 50 / 0.12), 0 2px 6px oklch(0.20 0.01 50 / 0.07), 0 0 0 1px oklch(0.20 0.01 50 / 0.06);
}

[data-theme="dark"] {
    --sp-shadow-xs: 0 1px 2px oklch(0 0 0 / 0.2);
    --sp-shadow-sm: 0 1px 3px oklch(0 0 0 / 0.3), 0 1px 2px oklch(0 0 0 / 0.2);
    --sp-shadow-md: 0 4px 8px oklch(0 0 0 / 0.35), 0 2px 4px oklch(0 0 0 / 0.2);
    --sp-shadow-lg: 0 10px 25px oklch(0 0 0 / 0.4), 0 4px 10px oklch(0 0 0 / 0.25);
    --sp-shadow-xl: 0 20px 40px oklch(0 0 0 / 0.5), 0 8px 16px oklch(0 0 0 / 0.3);
    --sp-shadow-inset-sm: inset 0 1px 2px oklch(0 0 0 / 0.2);
    --sp-shadow-card: 0 1px 3px oklch(0 0 0 / 0.4), 0 1px 2px oklch(0 0 0 / 0.3), 0 0 0 1px oklch(1.00 0 0 / 0.03);
    --sp-shadow-card-hover: 0 8px 24px oklch(0 0 0 / 0.5), 0 2px 6px oklch(0 0 0 / 0.3), 0 0 0 1px oklch(1.00 0 0 / 0.05);
    --sp-shadow-elevated: 0 4px 16px oklch(0 0 0 / 0.5), 0 2px 6px oklch(0 0 0 / 0.35), 0 0 0 1px oklch(1.00 0 0 / 0.04);
    --sp-shadow-float: 0 12px 40px oklch(0 0 0 / 0.55), 0 4px 12px oklch(0 0 0 / 0.3);
    --sp-shadow-accent-sm: 0 2px 8px color-mix(in oklch, var(--sp-accent) 18%, transparent);
    --sp-shadow-accent-md: 0 4px 20px color-mix(in oklch, var(--sp-accent) 22%, transparent);
    --sp-shadow-inner-glow: inset 0 1px 0 oklch(1.00 0 0 / 0.04);
    --sp-shadow-hero: 0 4px 16px oklch(0 0 0 / 0.4), 0 2px 4px oklch(0 0 0 / 0.3), 0 0 0 1px oklch(1.00 0 0 / 0.04);
    --sp-shadow-lift: 0 6px 20px oklch(0 0 0 / 0.45), 0 2px 6px oklch(0 0 0 / 0.3), 0 0 0 1px oklch(1.00 0 0 / 0.05);
}
}

@layer tokens {
:root {
    --sp-bg-surface-gradient: linear-gradient(180deg, oklch(1.0 0 0) 0%, oklch(0.98 0.004 70) 60%, oklch(0.96 0.005 70) 100%);
    --sp-bg-surface-raised-gradient: linear-gradient(135deg, oklch(1.0 0 0) 0%, oklch(0.97 0.004 70) 100%);
    --sp-bg-card-header: linear-gradient(180deg, oklch(0.97 0.005 65) 0%, oklch(0.95 0.006 65) 100%);
    --sp-bg-accent-wash: linear-gradient(135deg, color-mix(in oklch, var(--sp-accent) 6%, oklch(0.99 0.003 70)) 0%, oklch(0.99 0.003 70) 100%);
    --sp-bg-main: light-dark(oklch(0.95 0.005 70), oklch(0.18 0.01 45));
    --sp-bg-main-gradient: var(--sp-bg-main);
    --sp-bg-main-accent-tl: none;
    --sp-bg-main-accent-br: none;
    --sp-bg-glass: light-dark(oklch(1.00 0 0 / 0.65), oklch(0.21 0.01 48 / 0.78));
    --sp-bg-glass-border: light-dark(oklch(0.20 0.01 50 / 0.08), oklch(1.00 0 0 / 0.06));
    --sp-bg-hero-gradient: linear-gradient(180deg, oklch(1.0 0 0) 0%, oklch(0.98 0.004 70) 100%);

    --sp-scrollbar-width: 6px;
    --sp-scrollbar-track: transparent;
    --sp-scrollbar-thumb: light-dark(var(--sp-warm-300), var(--sp-warm-300));
    --sp-scrollbar-thumb-hover: light-dark(var(--sp-warm-400), var(--sp-warm-400));
    --sp-toggle-knob: light-dark(var(--sp-primitive-white), var(--sp-primitive-warm-50));
    --sp-shimmer-from: light-dark(var(--sp-warm-100), var(--sp-warm-100));
    --sp-shimmer-via:  light-dark(var(--sp-warm-50), var(--sp-warm-50));
    --sp-shimmer-to:   light-dark(var(--sp-warm-100), var(--sp-warm-100));
}

[data-theme="dark"] {
    --sp-bg-surface-gradient: linear-gradient(180deg, oklch(0.23 0.01 48) 0%, oklch(0.21 0.01 48) 60%, oklch(0.19 0.01 47) 100%);
    --sp-bg-surface-raised-gradient: linear-gradient(135deg, oklch(0.25 0.01 48) 0%, oklch(0.23 0.01 48) 100%);
    --sp-bg-card-header: linear-gradient(180deg, oklch(0.24 0.01 48) 0%, oklch(0.22 0.01 47) 100%);
    --sp-bg-accent-wash: linear-gradient(135deg, color-mix(in oklch, var(--sp-accent) 5%, oklch(0.21 0.01 48)) 0%, oklch(0.21 0.01 48) 100%);
    --sp-bg-main-gradient: var(--sp-bg-main);
    --sp-bg-main-accent-tl: none;
    --sp-bg-main-accent-br: none;
    --sp-bg-hero-gradient: var(--sp-bg-surface-raised-gradient);
}
}

@layer base {

.header-actions-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
    background: var(--sp-bg-surface);
    color: var(--sp-text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: color var(--sp-duration-fast), background var(--sp-duration-fast), border-color var(--sp-duration-fast);
}

.header-actions-toggle:hover {
    color: var(--sp-text-primary);
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-strong);
}

.header-actions-menu {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
}

.user-widget-row {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
}

.header-help-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
    border-radius: var(--sp-radius-md);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    color: var(--sp-text-secondary);
    cursor: pointer;
    transition: color var(--sp-duration-fast), background var(--sp-duration-fast), border-color var(--sp-duration-fast);
}
.header-help-link:hover {
    color: var(--sp-text-primary);
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-strong);
}
.header-help-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px color-mix(in oklch, var(--sp-accent) 50%, transparent);
}
.header-help-link svg {
    display: block;
}

.admin-layout h1, .admin-layout h2, .admin-layout h3 {
    font-family: var(--sp-font-heading);
}

.admin-layout a {
    color: var(--sp-text-secondary);
    text-decoration: none;
    transition: color var(--sp-duration-fast);
}

.admin-layout a:hover {
    color: var(--sp-text-primary);
}

.admin-layout .data-table a,
.admin-layout .clickable-row a {
    color: var(--sp-text-primary);
    font-weight: 500;
}

.admin-layout .data-table a:hover,
.admin-layout .clickable-row a:hover {
    color: var(--sp-accent);
}

[data-section="dashboard"]                          { --sp-section-color: var(--sp-section-dashboard); }
[data-section="users"],  [data-section="user-detail"] { --sp-section-color: var(--sp-section-users); }
[data-section="plugins"],[data-section="plugin-create"],
[data-section="plugin-edit"]                          { --sp-section-color: var(--sp-section-plugins); }
[data-section="skills"], [data-section="skill-edit"]  { --sp-section-color: var(--sp-section-skills); }
[data-section="export"]                               { --sp-section-color: var(--sp-section-export); }
[data-section="audit"]                                { --sp-section-color: var(--sp-section-audit); }
[data-section="agents"], [data-section="agent-edit"]  { --sp-section-color: var(--sp-section-dashboard); }
[data-section="hooks"],  [data-section="hook-edit"]   { --sp-section-color: var(--sp-section-dashboard); }
[data-section="mcp-servers"],[data-section="mcp-edit"]{ --sp-section-color: var(--sp-section-dashboard); }
[data-section="jobs"],   [data-section="events"]      { --sp-section-color: var(--sp-section-users); }
[data-section="leaderboard"],[data-section="achievements"] { --sp-section-color: var(--sp-section-dashboard); }
[data-section="contexts"], [data-section="context-detail"] { --sp-section-color: var(--sp-section-dashboard); }

.section-title {
    font-size: var(--sp-text-md);
    font-weight: 600;
    margin: var(--sp-space-8) 0 var(--sp-space-5);
    color: var(--sp-text-primary);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
}

}

@layer base {

.section-title::before {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--sp-section-color);
    border-radius: var(--sp-radius-xs);
    flex-shrink: 0;
    box-shadow: 0 0 8px color-mix(in oklch, var(--sp-section-color) 30%, transparent);
}

input[type="checkbox"] {
    accent-color: var(--sp-accent);
    cursor: pointer;
}

select {
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
}

select option {
    background: var(--sp-bg-surface-overlay);
    color: var(--sp-text-primary);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px color-mix(in oklch, var(--sp-accent) 50%, transparent);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialogIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast--leaving {
    opacity: 0;
    transition: opacity 350ms var(--sp-ease-out);
}

.value-lg { font-weight: 700; font-size: var(--sp-text-lg); }
.empty-placeholder { color: var(--sp-text-tertiary); text-align: center; padding: var(--sp-space-8); }
.loading-text { color: var(--sp-text-secondary); padding: var(--sp-space-4); }

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.admin-layout {
    scrollbar-width: thin;
    scrollbar-color: var(--sp-scrollbar-thumb) var(--sp-scrollbar-track);
}

.live-feed,
.activity-feed,
.alert-list,
.table-scroll {
    scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

}

@layer reset {
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--sp-font-family);
    color: var(--sp-text-primary);
    background: var(--sp-bg-base);
    line-height: 1.5;

}
}

@layer base {
.admin-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--sp-bg-base);
    color: var(--sp-text-primary);
    font-family: var(--sp-font-family);
    font-size: var(--sp-text-base);
    line-height: 1.5;

}

.admin-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--sp-bg-main-gradient);
    position: relative;
    display: flex;
    flex-direction: column;
    contain: layout style;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* One source of truth for the page gutter: full-bleed elements cancel it with
   calc(-1 * var(--sp-gutter)), so the two can never drift apart per breakpoint. */
.admin-main {
    --sp-gutter: var(--sp-space-10);
}

.admin-main > *:not(.admin-footer) {
    padding-left: var(--sp-gutter);
    padding-right: var(--sp-gutter);
}

/* A page section is sized by its content and the page scrolls. As shrinkable
   items of the 100vh .admin-main column they were squeezed to the space left
   over instead, and any section with a non-visible overflow (a bordered panel,
   a table card) has an automatic minimum size of zero — so it silently cropped
   its own content, and since nothing overflowed .admin-main there was nothing
   to scroll. */
.admin-main > *:not(.admin-footer) {
    flex: 0 0 auto;
}

/* Sections that are their own surface take the gutter as margin, not padding:
   given padding, the card's background runs edge to edge and its borders and
   corners sit off canvas while its content is inset twice over. */
.admin-main > .overview-pane,
.admin-main > .trace-detail__summary {
    padding-inline: 0;
    margin-inline: var(--sp-gutter);
}

header.admin-header,
.admin-main > .admin-header {
    padding-top: var(--sp-space-8);
}

.admin-main > .admin-footer {
    margin-top: auto;
}

.admin-main::before,
.admin-main::after {
    content: '';
    position: fixed;
    pointer-events: none;
    z-index: 0;
}

.admin-main::before {
    top: 0;
    left: 220px;
    right: 0;
    bottom: 0;
    background: var(--sp-bg-main-accent-tl);
}

.admin-main::after {
    top: 0;
    left: 220px;
    right: 0;
    bottom: 0;
    background: var(--sp-bg-main-accent-br);
}

.admin-main > * {
    position: relative;
    z-index: var(--sp-z-sticky);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: var(--sp-z-sticky-header);
    margin-bottom: var(--sp-space-7);
    padding-bottom: var(--sp-space-5);
    border-bottom: none;
    background-image: linear-gradient(90deg, var(--sp-border-subtle), var(--sp-border-subtle), transparent);
    background-size: 100% 1px;
    background-position: bottom;
    background-repeat: no-repeat;
}

.admin-header__spacer {
    flex: 1;
    min-height: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
}

}

@layer utilities {

.loading-shimmer {
    background: linear-gradient(90deg, var(--sp-shimmer-from) 25%, var(--sp-shimmer-via) 50%, var(--sp-shimmer-to) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--sp-radius-sm);
}

/* Full-bleed on the left only. Bleeding right as well ran the card — and, on a
   wide table, its scrollbar — under the window edge, so the content read as
   cut off rather than as a deliberate edge-to-edge treatment. The left bleed
   is what gives the brand asymmetric corner something to sit against. */
.admin-main .table-container,
.admin-main .toolbar {
    margin-left: calc(-1 * var(--sp-gutter));
    margin-right: 0;
    border-radius: 0 0.375rem 1.125rem 0;
    border-left: none;
}

/* The bleed moves the box, not its contents: a toolbar's own controls stay on
   the page gutter so their labels line up with the heading above them. */
.admin-main .toolbar {
    padding-left: var(--sp-gutter);
}

.admin-main .toolbar .search-input,
.admin-main .toolbar .filter-select {
    border-radius: 0 var(--sp-radius-button) var(--sp-radius-button) 0;
}

.admin-main .card,
.admin-main .alert-section,
.admin-main .stat-card {
    border-radius: 0 0.375rem 1.125rem 0;
}

.admin-main .card-header {
    border-radius: 0 var(--sp-radius-brand-tr) 0 0;
}

.admin-main .dashboard-grid,
.admin-main .stats-grid-3col {
    margin-left: calc(-1 * var(--sp-gutter));
    padding-left: var(--sp-gutter);
}

.admin-main .dashboard-two-col {
    margin-left: calc(-1 * var(--sp-gutter));
    padding-left: var(--sp-gutter);
}

.admin-main .card .table-container,
.admin-main .card-body--flush .table-container {
    margin-left: 0;
    border-radius: 0;
    border-left: none;
}

.admin-main .dashboard-two-col > *:nth-child(2n) > .card,
.admin-main .dashboard-two-col > *:nth-child(2n) > .table-container,
.admin-main .alerts-row > *:nth-child(2n) {
    border-radius: var(--sp-radius-card-brand);
    border-left: 1px solid var(--sp-border-subtle);
    margin-left: 0;
}

.admin-main .alert-danger {
    border-left: 4px solid var(--sp-danger);
}
.admin-main .alert-warning {
    border-left: 4px solid var(--sp-warning);
}
.entity-row-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--sp-accent); }

.field-label {
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
    margin-bottom: var(--sp-space-1);
    display: block;
}
.field-input {
    width: 100%;
    padding: var(--sp-space-2) var(--sp-space-3);
    font-size: var(--sp-text-sm);
    font-family: inherit;
    color: var(--sp-text-primary);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    transition: border-color var(--sp-duration-fast);
}
.field-input:focus { outline: none; border-color: var(--sp-accent); box-shadow: 0 0 0 2px color-mix(in oklch, var(--sp-accent) 20%, transparent); }
}

@layer utilities {
.text-semibold { font-weight: 600; }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--sp-danger); }
.text-success { color: var(--sp-success); }
.text-warning { color: var(--sp-warning); }
.text-muted { color: var(--sp-text-secondary); }
.text-tertiary { color: var(--sp-text-tertiary); }
.text-accent { color: var(--sp-accent); }
.text-xs { font-size: var(--sp-text-xs); }
.text-sm { font-size: var(--sp-text-sm); }
.text-lg { font-size: var(--sp-text-lg); }
.link-accent { color: var(--sp-accent); text-decoration: none; }
.clickable { cursor: pointer; }.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }.gap-4 { gap: var(--sp-space-4); }
.gap-6 { gap: var(--sp-space-6); }.mt-2 { margin-top: var(--sp-space-2); }
.mt-3 { margin-top: var(--sp-space-3); }
.mt-4 { margin-top: var(--sp-space-4); }.mb-2 { margin-bottom: var(--sp-space-2); }
.mb-3 { margin-bottom: var(--sp-space-3); }
.mb-4 { margin-bottom: var(--sp-space-4); }
.mb-6 { margin-bottom: var(--sp-space-6); }.p-4 { padding: var(--sp-space-4); }.w-full { width: 100%; }
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.border-top { border-top: 1px solid var(--sp-border-subtle); }
.border-bottom { border-bottom: 1px solid var(--sp-border-subtle); }.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.empty-center { text-align: center; padding: var(--sp-space-12); color: var(--sp-text-tertiary); }
.font-mono { font-family: 'Menlo', 'Consolas', monospace; }
.grid { display: grid; gap: var(--sp-space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.h-full { height: 100%; }
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.section-heading {
    font-size: var(--sp-text-md);
    font-weight: 600;
    margin: var(--sp-space-6) 0 var(--sp-space-4);
    color: var(--sp-text-primary);
    letter-spacing: -0.01em;
}
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-space-3); }
.grid-auto-fill { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-space-4); }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-space-3); }
.p-5 { padding: var(--sp-space-5); }
.stat-label { font-size: var(--sp-text-xs); color: var(--sp-text-tertiary); }
.stat-value { font-size: var(--sp-text-lg); font-weight: 700; color: var(--sp-text-primary); }
.card-title { font-weight: 600; font-size: var(--sp-text-md); color: var(--sp-text-primary); margin-bottom: var(--sp-space-3); }
.col-rank { width: 40px; }
.col-number { text-align: right; }
.sp-skip-link {
    position: absolute;
    top: -100%;
    left: var(--sp-space-2);
    padding: var(--sp-space-2) var(--sp-space-4);
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    border-radius: 0 0 var(--sp-radius-sm) var(--sp-radius-sm);
    z-index: var(--sp-z-toast);
    text-decoration: none;
    font-weight: 600;
    transition: top var(--sp-duration-fast) var(--sp-ease-out);
}
.sp-skip-link:focus-visible {
    top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.health-value,
.stat-card .value,
.bar-value,
.skill-bar-count {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

}

@layer components {

.admin-header__search {
    flex: 1 1 auto;
    max-width: 640px;
    margin: 0 var(--sp-space-4);
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    padding: 0 var(--sp-space-3);
    height: 36px;
    background: var(--sp-surface-2, oklch(0.98 0.003 70));
    border: 1px solid var(--sp-border-subtle, oklch(0.9 0.005 70));
    border-radius: 999px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    position: relative;
}

[data-theme="dark"] .admin-header__search {
    background: var(--sp-surface-2, oklch(0.22 0.01 45));
    border-color: var(--sp-border-subtle, oklch(0.3 0.01 45));
}

.admin-header__search:focus-within {
    border-color: var(--sp-brand-primary, oklch(0.62 0.18 250));
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--sp-brand-primary, oklch(0.62 0.18 250)) 20%, transparent);
    background: var(--sp-surface-1, white);
}

[data-theme="dark"] .admin-header__search:focus-within {
    background: var(--sp-surface-1, oklch(0.18 0.01 45));
}

.admin-header__search--error {
    border-color: var(--sp-danger, oklch(0.62 0.2 25));
}

.admin-header__search--error:focus-within {
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--sp-danger, oklch(0.62 0.2 25)) 20%, transparent);
}

.admin-header__search-icon {
    flex: none;
    color: var(--sp-text-muted, oklch(0.55 0.01 70));
    pointer-events: none;
}

.admin-header__search-input,
#admin-header-search-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    font: inherit;
    font-size: var(--sp-text-sm, 14px);
    color: var(--sp-text-primary, inherit);
    padding: 0;
    margin: 0;
}

#admin-header-search-input::placeholder {
    color: var(--sp-text-muted, oklch(0.6 0.01 70));
}

#admin-header-search-input::-webkit-search-cancel-button {
    appearance: none;
}

.admin-header__search-hint {
    flex: none;
    font-family: var(--sp-font-mono, ui-monospace, monospace);
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 4px;
    color: var(--sp-text-muted, oklch(0.55 0.01 70));
    background: var(--sp-surface-3, oklch(0.94 0.004 70));
    border: 1px solid var(--sp-border-subtle, oklch(0.9 0.005 70));
}

[data-theme="dark"] .admin-header__search-hint {
    background: var(--sp-surface-3, oklch(0.26 0.01 45));
    border-color: var(--sp-border-subtle, oklch(0.32 0.01 45));
}

.admin-header__search-status {
    flex: none;
    font-size: 11px;
    color: var(--sp-text-muted, oklch(0.55 0.01 70));
    white-space: nowrap;
}

.admin-header__search--error .admin-header__search-status {
    color: var(--sp-danger, oklch(0.55 0.2 25));
}

.admin-header__search--loading .admin-header__search-icon {
    animation: admin-header-search-spin 0.9s linear infinite;
}

@keyframes admin-header-search-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
    .admin-header__search {
        max-width: none;
        margin: 0 var(--sp-space-2);
    }
    .admin-header__search-hint,
    .admin-header__search-status {
        display: none;
    }
}

}

@layer components {

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-1);
    margin-bottom: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
}

.breadcrumbs a {
    color: var(--sp-text-secondary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--sp-accent);
    text-decoration: underline;
}

.breadcrumbs__sep {
    color: var(--sp-text-tertiary);
    user-select: none;
}

.breadcrumbs [aria-current="page"] {
    color: var(--sp-text-primary);
    font-weight: 500;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-space-6);
    margin-bottom: var(--sp-space-6);
    padding-bottom: var(--sp-space-4);
    border-bottom: 1px solid var(--sp-border-subtle);
}

.page-header__title-group {
    flex: 1 1 auto;
    min-width: 0;
}

.page-header__title {
    font-family: var(--sp-font-heading);
    font-size: var(--sp-text-2xl);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--sp-text-primary);
}

.page-header__subtitle {
    margin: var(--sp-space-1) 0 0;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    line-height: 1.5;
}@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        gap: var(--sp-space-3);
        align-items: stretch;
    }}

}

@layer components {

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--sp-text-secondary);
    cursor: pointer;
    padding: var(--sp-space-2);
    border-radius: var(--sp-radius-sm);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    transition: color var(--sp-duration-fast), background var(--sp-duration-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--sp-accent-dim);
    color: var(--sp-text-primary);
}

.sidebar-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px var(--sp-accent);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0);
    z-index: var(--sp-z-sidebar);
    transition: background var(--sp-duration-slow) var(--sp-ease-in-out);
}

.sidebar-overlay.open {
    display: block;
    background: var(--sp-overlay-light);
    backdrop-filter: blur(2px);
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: var(--sp-space-3);
    right: var(--sp-space-3);
    width: 36px;
    height: 36px;
    border: none;
    background: light-dark(var(--sp-primitive-warm-200), oklch(1.00 0 0 / 0.1));
    color: var(--sp-sidebar-text);
    border-radius: var(--sp-radius-sm);
    cursor: pointer;
    font-size: var(--sp-text-md);
    line-height: 1;
    z-index: var(--sp-z-sticky);
    align-items: center;
    justify-content: center;
    transition: background var(--sp-duration-fast), color var(--sp-duration-fast);
}

.sidebar-close-btn:hover {
    background: light-dark(var(--sp-primitive-warm-300), oklch(1.00 0 0 / 0.15));
    color: var(--sp-sidebar-text-hover);
}

.sidebar-close-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-sidebar-bg), 0 0 0 4px var(--sp-sidebar-active-color);
}

.admin-sidebar {
    scrollbar-width: thin;
    scrollbar-color: light-dark(var(--sp-primitive-warm-300), oklch(1.00 0 0 / 0.15)) transparent;
}

.sidebar-footer {
    padding: var(--sp-space-3) var(--sp-space-4);
    border-top: 1px solid var(--sp-sidebar-border);
    flex-shrink: 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    width: 100%;
    padding: var(--sp-space-2) var(--sp-space-3);
    border: none;
    border-radius: var(--sp-radius-sm);
    background: transparent;
    color: var(--sp-sidebar-text);
    font-size: var(--sp-text-sm);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--sp-duration-fast) var(--sp-ease-in-out),
                color var(--sp-duration-fast) var(--sp-ease-in-out);
}

.theme-toggle:hover {
    background: var(--sp-sidebar-hover-bg);
    color: var(--sp-sidebar-text-hover);
    border-radius: var(--sp-radius-button);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-sidebar-bg), 0 0 0 4px var(--sp-sidebar-active-color);
}

.theme-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--sp-duration-fast);
}

.theme-toggle:hover .theme-icon {
    opacity: 0.85;
}

.theme-icon--dark { display: none; }

[data-theme="dark"] .theme-icon--light { display: none; }
[data-theme="dark"] .theme-icon--dark { display: inline; }

@media (prefers-reduced-motion: reduce) {
    .sidebar-overlay {
        transition: none;
    }
}

}

@layer components {
.admin-sidebar {
    width: 220px;
    background: var(--sp-sidebar-bg);
    border-right: 1px solid var(--sp-sidebar-border);
    box-shadow: none;
    padding: 0;
    flex-shrink: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.admin-sidebar-brand {
    padding: var(--sp-space-6) var(--sp-space-5);
    text-decoration: none;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--sp-sidebar-border);
    background: none;
}

.admin-logo {
    width: 160px;
    height: auto;
}

.admin-logo--dark { display: none; }
[data-theme="dark"] .admin-logo--light { display: none; }
[data-theme="dark"] .admin-logo--dark { display: inline; }

[data-theme="dark"] .admin-sidebar {
    box-shadow: inset -1px 0 0 oklch(1.00 0 0 / 0.04);
}

[data-theme="dark"] .admin-sidebar-brand {
    background: linear-gradient(180deg, oklch(1.00 0 0 / 0.03) 0%, transparent 100%);
}

.admin-sidebar nav {
    flex: 1;
    padding: var(--sp-space-3) 0;
}

.nav-label {
    padding: var(--sp-space-5) var(--sp-space-5) var(--sp-space-2);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sp-sidebar-text-muted);
}

.nav-label:first-child {
    padding-top: var(--sp-space-3);
}

.admin-sidebar nav h2.nav-label:nth-of-type(1) { color: var(--sp-nav-label-1); }
.admin-sidebar nav h2.nav-label:nth-of-type(2) { color: var(--sp-nav-label-2); }
.admin-sidebar nav h2.nav-label:nth-of-type(3) { color: var(--sp-nav-label-3); }
.admin-sidebar nav h2.nav-label:nth-of-type(4) { color: var(--sp-nav-label-4); }
.admin-sidebar nav h2.nav-label:nth-of-type(5) { color: var(--sp-nav-label-5); }

h2.nav-label {
    margin: 0;
    font-weight: inherit;
}

.nav-label-sub {
    font-size: var(--sp-text-xs);
    padding: var(--sp-space-4) var(--sp-space-5) var(--sp-space-1);
}

.admin-sidebar nav a {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    padding: var(--sp-space-2) var(--sp-space-5);
    margin: 0.0625rem var(--sp-space-2);
    color: var(--sp-sidebar-text);
    text-decoration: none;
    transition: background var(--sp-duration-fast) var(--sp-ease-in-out),
                color var(--sp-duration-fast) var(--sp-ease-in-out);
    font-size: var(--sp-text-sm);
    font-weight: 500;
    border-radius: var(--sp-radius-sm);
    min-width: 0;
    overflow: hidden;
}

.admin-sidebar nav a:hover {
    background: var(--sp-sidebar-hover-bg);
    color: var(--sp-sidebar-text-hover);
}

.admin-sidebar nav a.active {
    background: var(--sp-sidebar-active-bg);
    color: var(--sp-sidebar-active-color);
    font-weight: 600;
    position: relative;
    padding-left: var(--sp-space-5);
}

.admin-sidebar nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: var(--sp-radius-full);
    background: var(--sp-sidebar-active-color);
    box-shadow: 0 0 8px color-mix(in oklch, var(--sp-sidebar-active-color) 40%, transparent);
}

.admin-sidebar nav a .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--sp-duration-fast);
}

.admin-sidebar nav a:hover .icon { opacity: 0.85; }
.admin-sidebar nav a.active .icon { opacity: 1; }

.admin-sidebar nav a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-sidebar-bg), 0 0 0 4px var(--sp-sidebar-active-color);
}

.nav-badge {
    margin-left: auto;
    flex-shrink: 0;
    background: color-mix(in oklch, var(--sp-danger) 20%, transparent);
    color: var(--sp-nav-badge-text);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    padding: 0.0625rem 0.4375rem;
    border-radius: var(--sp-radius-full);
}

/* Collapsible nav groups (Explore drawer) */
.admin-sidebar nav .nav-group {
    margin: 0;
}

.admin-sidebar nav .nav-group > summary {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    padding: var(--sp-space-2) var(--sp-space-5);
    margin: 0.0625rem var(--sp-space-2);
    color: var(--sp-sidebar-text);
    font-size: var(--sp-text-sm);
    font-weight: 500;
    border-radius: var(--sp-radius-sm);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.admin-sidebar nav .nav-group > summary::-webkit-details-marker { display: none; }
.admin-sidebar nav .nav-group > summary::marker { content: ''; }

.admin-sidebar nav .nav-group > summary:hover {
    background: var(--sp-sidebar-hover-bg);
    color: var(--sp-sidebar-text-hover);
}

.admin-sidebar nav .nav-group > summary .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}

.nav-group-chevron {
    width: 12px;
    height: 12px;
    margin-left: auto;
    opacity: 0.5;
    transition: transform var(--sp-duration-fast) var(--sp-ease-in-out);
}

.admin-sidebar nav .nav-group[open] > summary .nav-group-chevron {
    transform: rotate(180deg);
}

.admin-sidebar nav .nav-group > a {
    padding-left: calc(var(--sp-space-5) + 16px + var(--sp-space-3));
    font-size: var(--sp-text-sm);
    color: var(--sp-sidebar-text-muted, var(--sp-sidebar-text));
    opacity: 0.85;
}

.admin-sidebar nav .nav-group > a:hover {
    opacity: 1;
}

/* Account footer group — visually demoted */
.nav-label--account {
    margin-top: var(--sp-space-6);
    border-top: 1px solid var(--sp-sidebar-border);
    padding-top: var(--sp-space-5);
    color: var(--sp-sidebar-text-muted) !important;
}

.nav-external {
    margin-left: auto;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

}

@layer components {
/* Tables grow with their content and the page scrolls; an internal
   max-height silently hides rows behind an unmarked inner scrollbar. */
.table-container {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand);
    box-shadow: var(--sp-shadow-card), var(--sp-shadow-inner-glow);
    max-width: 100%;
}

/* Only the inner element scrolls. Both used to, which produced two nested
   scrollbars on a wide table and let the inner one sit outside the card's
   rounded corner. */
.table-scroll {
    overflow-x: auto;
    border-radius: inherit;
}

/* Classic CSS scroll shadow: the `local` layers mask the `scroll` shadows
   until the content actually overflows, so the cue only appears when there
   is something more to see sideways. */
.table-scroll {
    background-image:
        linear-gradient(to right, var(--sp-bg-surface), transparent),
        linear-gradient(to left, var(--sp-bg-surface), transparent),
        linear-gradient(to right, color-mix(in oklch, var(--sp-warm-900) 12%, transparent), transparent),
        linear-gradient(to left, color-mix(in oklch, var(--sp-warm-900) 12%, transparent), transparent);
    background-position: left center, right center, left center, right center;
    background-repeat: no-repeat;
    background-size: 2.5rem 100%, 2.5rem 100%, 1rem 100%, 1rem 100%;
    background-attachment: local, local, scroll, scroll;
}

/* A table is sized by its rows and the page scrolls; 02-base-layout.css states
   that once, for every page section, so there is no per-element rule here. */

.data-table {
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table .col-thumbnail   { width: 56px; min-width: 56px; max-width: 56px; }
.data-table .col-date        { width: 100px; min-width: 90px; }
.data-table .col-currency    { width: 110px; min-width: 95px; }
.data-table .col-status      { width: 110px; min-width: 90px; }
.data-table .col-boolean     { width: 70px; min-width: 60px; }
.data-table .col-badge_count { width: 80px; min-width: 70px; }
.data-table .col-tags        { width: 150px; min-width: 120px; }
.data-table .col-text        { min-width: 100px; }

.data-table th {
    background: var(--sp-bg-card-header);
    padding: var(--sp-space-4) var(--sp-space-4);
    text-align: left;
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
    border-bottom: 1px solid var(--sp-border-default);
    background-image: linear-gradient(90deg, transparent, var(--sp-border-subtle), transparent);
    background-size: 100% 1px;
    background-position: bottom;
    background-repeat: no-repeat;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: var(--sp-z-sticky);
}

.data-table th:hover {
    color: var(--sp-text-secondary);
}

.data-table th .sort-icon {
    display: inline-block;
    margin-left: var(--sp-space-1);
    opacity: 0.3;
    transition: opacity var(--sp-duration-fast);
}

.data-table th.sorted .sort-icon {
    opacity: 1;
    color: var(--sp-accent);
}

.data-table td {
    padding: var(--sp-space-4) var(--sp-space-4);
    border-bottom: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-sm);
    line-height: 1.5;
    color: var(--sp-text-secondary);
    vertical-align: top;
}

.data-table td.truncate {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td:first-child {
    color: var(--sp-text-primary);
    font-weight: 500;
}

.data-table tbody tr:nth-child(even) td {
    background: color-mix(in oklch, var(--sp-warm-900) 2%, transparent);
}

.data-table tr:hover td {
    background: color-mix(in oklch, var(--sp-warm-900) 4%, transparent);
}

.data-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--sp-section-color);
}

.data-table tr.selected td {
    background: var(--sp-accent-dim);
}

.data-table tbody tr:nth-child(even) td.col-actions,
.data-table tr:hover td.col-actions,
.data-table .clickable-row:hover td.col-actions {
    background: var(--sp-bg-surface);
}

.data-table td.col-actions {
    white-space: nowrap;
    text-align: center;
    padding: var(--sp-space-2) var(--sp-space-3) var(--sp-space-2) var(--sp-space-4);
    position: sticky;
    right: 0;
    background: var(--sp-bg-surface);
    border-left: 1px solid var(--sp-border-subtle);
    z-index: var(--sp-z-sticky-header);
    vertical-align: middle;
}

.data-table th.col-actions {
    width: 60px;
    text-align: center;
    position: sticky;
    right: 0;
    background: var(--sp-bg-surface-raised);
    border-left: 1px solid var(--sp-border-subtle);
    z-index: var(--sp-z-sticky-header);
}

.data-table td.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.data-table td.date {
    white-space: nowrap;
    color: var(--sp-text-tertiary);
}

.data-table th.numeric { text-align: right; }

.data-table th.rate-col,
.data-table td.rate-col {
    text-align: right;
    min-width: 120px;
    white-space: nowrap;
}

.data-table .empty-state {
    text-align: center;
    padding: var(--sp-space-12) var(--sp-space-4);
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-base);
}

.clickable-row {
    cursor: pointer;
    transition: background var(--sp-duration-fast);
}

.clickable-row:hover td {
    background: var(--sp-accent-dim);
}

/* Right-aligned numeric columns (header + cell). */
.data-table th.col-num,
.data-table td.col-num,
.data-table th.col-numeric,
.data-table td.col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.row-expandable {
    cursor: pointer;
    transition: background var(--sp-duration-fast);
}

}

@layer components {

.badge-purple {
    background: var(--sp-badge-purple-dim);
    color: var(--sp-badge-purple);
}

.badge-blue {
    background: var(--sp-accent-dim);
    color: var(--sp-accent);
}

.badge-yellow {
    background: var(--sp-warning-dim);
    color: var(--sp-warning);
}
.table-preview {
    max-height: 200px;
    overflow: auto;
}

.detail-data-table {
    width: 100%;
    font-size: var(--sp-text-sm);
    border-collapse: collapse;
}
.detail-data-table th,
.detail-data-table td {
    padding: var(--sp-space-2) var(--sp-space-1);
}
.detail-data-table thead tr {
    text-align: left;
    border-bottom: 2px solid var(--sp-border-default);
}
.detail-data-table tbody tr {
    border-bottom: 1px solid var(--sp-border-default);
}

@media (max-width: 768px) {
    .table-container {
        margin-left: calc(-1 * var(--sp-space-3));
        margin-right: calc(-1 * var(--sp-space-3));
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-x: auto;
        overflow-y: visible;
    }

    .admin-main > .table-container {
        flex: none;
        min-height: 0;
    }

    .admin-main > .table-container > .table-scroll {
        flex: none;
        max-height: 60vh;
    }

    .table-scroll {
        max-height: 60vh;
        overflow-x: auto;
    }

    .data-table th {
        padding: var(--sp-space-2) var(--sp-space-3);
        font-size: var(--sp-text-xs);
    }

    .data-table td {
        padding: var(--sp-space-2) var(--sp-space-3);
        font-size: var(--sp-text-sm);
    }

    .data-table td.col-actions {
        padding: var(--sp-space-1) var(--sp-space-2);
    }

    .col-checkbox input[type="checkbox"] {
        min-width: 44px;
        min-height: 44px;
    }

    .pagination {
        flex-direction: column;
        gap: var(--sp-space-2);
        padding: var(--sp-space-2) var(--sp-space-3);
        font-size: var(--sp-text-xs);
    }

    .pagination-controls button {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 767px) {
    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        z-index: var(--sp-z-sticky);
        background: var(--sp-bg-surface);
    }

    .data-table th:first-child {
        background: var(--sp-bg-card-header);
    }
}

@media (max-width: 480px) {
    .table-container {
        margin-left: calc(-1 * var(--sp-space-2));
        margin-right: calc(-1 * var(--sp-space-2));
    }
}

}

@layer components {

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-space-3) var(--sp-space-4);
    border-top: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: var(--sp-space-4);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-space-1);
}

.pagination-controls button {
    background: none;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    color: var(--sp-text-secondary);
    padding: var(--sp-space-1) var(--sp-space-3);
    cursor: pointer;
    font-size: var(--sp-text-sm);
    font-family: inherit;
    transition: background var(--sp-duration-fast), border-color var(--sp-duration-fast), color var(--sp-duration-fast);
}

.pagination-controls button:hover:not(:disabled) {
    background: color-mix(in oklch, var(--sp-warm-900) 4%, transparent);
    border-color: var(--sp-border-strong);
    color: var(--sp-text-primary);
}

.pagination-controls button:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Ends of the range render as spans, not links: same shape, no target. */
.pagination-controls .is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pagination-controls .current-page {
    padding: var(--sp-space-1) var(--sp-space-3);
    color: var(--sp-accent);
    font-weight: 600;
}

.per-page-select {
    background: transparent;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    color: var(--sp-text-secondary);
    padding: var(--sp-space-1) var(--sp-space-2);
    font-size: var(--sp-text-sm);
    font-family: inherit;
}

.per-page-select:focus-visible,
.pagination-controls button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px var(--sp-accent);
}

.data-table tfoot tr {
    background: var(--sp-bg-surface-raised);
}

.data-table tfoot td {
    background: inherit;
    border-top: 2px solid var(--sp-border-default);
    border-bottom: none;
    font-weight: 700;
    color: var(--sp-text-primary);
    padding: var(--sp-space-3) var(--sp-space-4);
    font-size: var(--sp-text-sm);
    white-space: nowrap;
}

.data-table tfoot td.col-actions {
    background: inherit;
}.data-table .thumbnail-cell {
    width: 56px;
    padding: var(--sp-space-1);
    text-align: center;
}

.table-thumbnail {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: var(--sp-radius-sm);
    border: 1px solid var(--sp-border-subtle);
}

.table-thumbnail-empty {
    display: inline-block;
    width: 48px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    color: var(--sp-text-tertiary);
}

.data-table .col-checkbox {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
    padding: var(--sp-space-2);
}

.col-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.data-table .col-multiline {
    white-space: normal;
    line-height: 1.4;
}

.cell-stacked {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.cell-primary {
    font-weight: 500;
    color: var(--sp-text-primary);
}

.cell-secondary {
    font-size: 0.8em;
    color: var(--sp-text-tertiary);
    margin-top: 0.125rem;
}

.data-table tbody.table-group + tbody.table-group .table-group-header th {
    border-top: 1px solid var(--sp-border-default);
}

.data-table .table-group-header th {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: var(--sp-space-2) var(--sp-space-4);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-group-title {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
}

.table-group-title:hover .table-group-name {
    color: var(--sp-accent);
}

.table-group-name {
    color: var(--sp-text-primary);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.table-group-count {
    color: var(--sp-text-tertiary);
    font-weight: 500;
    font-size: var(--sp-text-xs);
}

.table-group-stats {
    float: right;
    color: var(--sp-text-tertiary);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.user-cell-text {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.user-cell-name {
    color: var(--sp-text-primary);
    font-weight: 500;
}

.user-cell-email {
    font-size: 0.78em;
    color: var(--sp-text-tertiary);
    margin-top: 0.1rem;
}

/* A model id is one token — wrapping it mid-name triples the row height and
   makes it harder to read, so the column scrolls with the table instead. */
.data-table td.col-model {
    white-space: nowrap;
}

/* ── list-page pagination footer ─────────────────────────────── */

.table-paginate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-space-2);
    margin-top: var(--sp-space-4);
}

.table-paginate__info {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* The "you are here" line above a list: present, but never the headline. */
.session-current {
    margin-bottom: var(--sp-space-4);
}

}

@layer components {

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem var(--sp-space-2);
    border-radius: var(--sp-radius-badge);
    font-size: var(--sp-text-xs);
    font-weight: 500;
    border: 1px solid color-mix(in oklch, currentColor 15%, transparent);
}

.status-active {
    background: var(--sp-success-dim);
    color: var(--sp-success);
}

.status-inactive {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-tertiary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem var(--sp-space-2);
    border-radius: var(--sp-radius-badge);
    font-size: var(--sp-text-xs);
    font-weight: 500;
    border: 1px solid color-mix(in oklch, currentColor 15%, transparent);
    line-height: 1.4;
    white-space: nowrap;
}

.badge-subtle {
    background: var(--sp-bg-surface-raised);
    padding: 0.125rem var(--sp-space-2);
    border-radius: var(--sp-radius-xs);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
}

.badge-green,
.badge-success { color: var(--sp-success); background: var(--sp-success-dim); border-color: color-mix(in oklch, var(--sp-success) 15%, transparent); }
.badge-red,
.badge-danger { color: var(--sp-danger); background: var(--sp-danger-dim); border-color: color-mix(in oklch, var(--sp-danger) 15%, transparent); }
.badge-warning { color: var(--sp-warning); background: color-mix(in oklch, var(--sp-warning) 12%, transparent); border-color: color-mix(in oklch, var(--sp-warning) 15%, transparent); }
.badge-info { color: var(--sp-accent); background: color-mix(in oklch, var(--sp-accent) 12%, transparent); border-color: color-mix(in oklch, var(--sp-accent) 15%, transparent); }
.badge-gray,
.badge-secondary { color: var(--sp-text-secondary); background: var(--sp-bg-tertiary); border-color: var(--sp-border-subtle); }
.badge-orange { color: var(--sp-section-export); background: color-mix(in oklch, var(--sp-section-export) 12%, transparent); border-color: color-mix(in oklch, var(--sp-section-export) 15%, transparent); }
.badge-sm { font-size: var(--sp-text-xs); padding: 0.0625rem var(--sp-space-1); }

.badge-muted {
    color: var(--sp-text-tertiary);
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-subtle);
}

/* mcp-badge — compact status pill used across governance, trace, and
   audit tables. Same shape as .badge, tuned smaller for dense rows. */
.mcp-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: 0.0625rem var(--sp-space-2);
    border-radius: var(--sp-radius-badge);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.02em;
    white-space: nowrap;
    color: var(--sp-text-secondary);
    background: var(--sp-bg-surface-raised);
    border: 1px solid color-mix(in oklch, currentColor 15%, transparent);
}

.mcp-badge-success {
    color: var(--sp-success);
    background: var(--sp-success-dim);
    border-color: color-mix(in oklch, var(--sp-success) 15%, transparent);
}

.mcp-badge-danger {
    color: var(--sp-danger);
    background: var(--sp-danger-dim);
    border-color: color-mix(in oklch, var(--sp-danger) 15%, transparent);
}

.mcp-badge-warning {
    color: var(--sp-warning);
    background: color-mix(in oklch, var(--sp-warning) 12%, transparent);
    border-color: color-mix(in oklch, var(--sp-warning) 15%, transparent);
}

}

@layer components {

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-2) var(--sp-space-4);
    border: 1px solid transparent;
    border-radius: var(--sp-radius-button);
    font-size: var(--sp-text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--sp-duration-fast) var(--sp-ease-in-out),
                color var(--sp-duration-fast) var(--sp-ease-in-out),
                border-color var(--sp-duration-fast) var(--sp-ease-in-out),
                box-shadow var(--sp-duration-fast) var(--sp-ease-in-out),
                transform var(--sp-duration-fast) var(--sp-ease-in-out);
    text-decoration: none;
    white-space: nowrap;
    line-height: 20px;
}

.btn:active { transform: scale(0.97); }

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px var(--sp-accent);
}

.btn-primary {
    background: linear-gradient(180deg, var(--sp-accent) 0%, var(--sp-accent-hover) 100%);
    color: var(--sp-text-on-accent);
    border-color: var(--sp-accent);
    box-shadow: var(--sp-shadow-accent-sm);
}

.btn-primary:hover {
    background: linear-gradient(180deg, color-mix(in oklch, var(--sp-accent) 85%, white) 0%, var(--sp-accent) 100%);
    border-color: var(--sp-accent-hover);
    box-shadow: var(--sp-shadow-accent-md);
}

.btn-primary:active {
    box-shadow: var(--sp-shadow-xs);
}

.btn-secondary {
    background: transparent;
    color: var(--sp-text-secondary);
    border-color: var(--sp-border-default);
    box-shadow: var(--sp-shadow-xs);
}

.btn-secondary:hover {
    background: color-mix(in oklch, var(--sp-warm-900) 4%, transparent);
    border-color: var(--sp-border-strong);
    color: var(--sp-text-primary);
}

.btn-danger {
    background: transparent;
    color: var(--sp-danger);
    border-color: color-mix(in oklch, var(--sp-danger) 30%, transparent);
    box-shadow: var(--sp-shadow-xs);
}

.btn-danger:hover {
    background: var(--sp-danger-dim);
    border-color: color-mix(in oklch, var(--sp-danger) 50%, transparent);
}

.btn-view {
    background: transparent;
    color: var(--sp-accent);
    border-color: color-mix(in oklch, var(--sp-accent) 30%, transparent);
    box-shadow: var(--sp-shadow-xs);
}

.btn-view:hover {
    background: var(--sp-accent-dim);
    border-color: var(--sp-accent);
}

.btn-sm {
    padding: var(--sp-space-1) var(--sp-space-3);
    font-size: var(--sp-text-xs);
}

.btn-icon {
    padding: var(--sp-space-2);
    min-width: 36px;
    justify-content: center;
}

.btn-sm.btn-icon {
    padding: var(--sp-space-1);
    min-width: 28px;
    font-size: var(--sp-text-sm);
}

.btn-outline {
    background: transparent;
    color: var(--sp-text-secondary);
    border-color: var(--sp-border-default);
}
.btn-outline:hover {
    background: color-mix(in oklch, var(--sp-warm-900) 4%, transparent);
    border-color: var(--sp-border-strong);
    color: var(--sp-text-primary);
}

.btn-outline-primary {
    background: transparent;
    color: var(--sp-accent);
    border-color: color-mix(in oklch, var(--sp-accent) 40%, transparent);
}
.btn-outline-primary:hover {
    background: var(--sp-accent-dim);
    border-color: var(--sp-accent);
}

.btn-outline-danger {
    background: transparent;
    color: var(--sp-danger);
    border-color: color-mix(in oklch, var(--sp-danger) 40%, transparent);
}
.btn-outline-danger:hover {
    background: var(--sp-danger-dim);
    border-color: var(--sp-danger);
}

.btn-ghost {
    background: transparent;
    color: var(--sp-text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: color-mix(in oklch, var(--sp-warm-900) 4%, transparent);
    color: var(--sp-text-primary);
}

/* borderless tertiary — like btn-ghost but tuned for inline install actions */
.btn-tertiary {
    background: transparent;
    color: var(--sp-accent);
    border-color: transparent;
    box-shadow: none;
}
.btn-tertiary:hover {
    background: var(--sp-accent-dim);
    color: var(--sp-accent-hover);
}

/* size modifiers used by plugin/version cards and detail tabs */
.btn--xs {
    padding: 0.0625rem var(--sp-space-2);
    font-size: var(--sp-text-xs);
}
.btn--files {
    flex-shrink: 0;
    align-self: flex-start;
}

@media (prefers-reduced-motion: reduce) {
    .btn {
        transition: none;
    }
    .btn:active {
        transform: none;
    }
}

}

@layer components {

/* `.table-container` and `.table-scroll` belong to 04-tables-core.css. This
   file used to redeclare both, and since `08-` bundles after `04-` its
   `max-height` won, clipping every admin table behind an unmarked inner
   scrollbar. */

.card {
    background: var(--sp-bg-surface-gradient);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand);
    padding: var(--sp-space-6);
    box-shadow: var(--sp-shadow-card), var(--sp-shadow-inner-glow);
    transition: box-shadow var(--sp-duration-normal) var(--sp-ease-out),
                border-color var(--sp-duration-normal);
}

.card:hover {
    box-shadow: var(--sp-shadow-card-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    background: var(--sp-bg-card-header);
    margin: calc(-1 * var(--sp-space-6)) calc(-1 * var(--sp-space-6)) var(--sp-space-4);
    padding: var(--sp-space-4) var(--sp-space-6);
    border-radius: 0 var(--sp-radius-brand-tr) 0 0;
    border-bottom: 1px solid var(--sp-border-subtle);
}

.card-header .card-title {
    margin-bottom: 0;
}

.card-body--flush {
    margin: 0 calc(-1 * var(--sp-space-6)) calc(-1 * var(--sp-space-6));
}

.card-body--flush .table-container {
    border: none;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--sp-border-subtle);
}

.card > h3:first-child {
    font-size: var(--sp-text-base);
    font-weight: 600;
    color: var(--sp-text-primary);
    margin: 0 0 var(--sp-space-4);
    padding-bottom: var(--sp-space-3);
    border-bottom: 1px solid var(--sp-border-subtle);
}

/* Body region beneath a .card-header. The header uses negative margins to
   bleed to the card edges, so the body just needs its natural flow; the
   colour + spacing come from the card. */
.card-body {
    color: var(--sp-text-secondary);
}

.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

.card-subtitle {
    margin: var(--sp-space-1) 0 0;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
}

}

/* Styling for shared component partials that the class gate surfaced as
   unstyled. Grouped by the partial each block backs. Tokens only. */

@layer components {

/* ── panel.hbs — .gf-panel (dashboard panel with header row) ──── */
.gf-panel {
    display: flex;
    flex-direction: column;
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand);
    box-shadow: var(--sp-shadow-card), var(--sp-shadow-inner-glow);
    overflow: hidden;
    min-width: 0;
}

.gf-panel__header {
    display: flex;
    align-items: baseline;
    gap: var(--sp-space-2);
    padding: var(--sp-space-3) var(--sp-space-4);
    background: var(--sp-bg-card-header);
    border-bottom: 1px solid var(--sp-border-subtle);
}

.gf-panel__title {
    font-size: var(--sp-text-base);
    font-weight: 600;
    color: var(--sp-text-primary);
    text-decoration: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
a.gf-panel__title:hover { color: var(--sp-accent); }

.gf-panel__subtitle {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.gf-panel__spacer { flex: 1; }

.gf-panel__open {
    color: var(--sp-text-tertiary);
    text-decoration: none;
    font-size: var(--sp-text-md);
    line-height: 1;
    transition: color var(--sp-duration-fast);
}
.gf-panel__open:hover { color: var(--sp-accent); }

.gf-panel__body {
    padding: var(--sp-space-4);
    min-width: 0;
}

/* ── plugin-card.hbs / version-card.hbs ───────────────────────── */
.plugin-card {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand);
    box-shadow: var(--sp-shadow-card);
    overflow: hidden;
}
.plugin-card--accent { border-left: 3px solid var(--sp-accent); }
.plugin-card--warning { border-left: 3px solid var(--sp-warning); }
.version-card { min-width: 0; }

.plugin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-space-3);
    padding: var(--sp-space-4);
    cursor: pointer;
}

.plugin-card__body { min-width: 0; flex: 1; }

.plugin-card__title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
}

.plugin-card__title {
    margin: 0;
    font-size: var(--sp-text-base);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.plugin-card__description {
    margin: var(--sp-space-1) 0 0;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

.plugin-card__date {
    margin-top: var(--sp-space-1);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.plugin-meta,
.plugin-card__tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-1);
    margin-top: var(--sp-space-2);
}

.plugin-depends {
    margin-top: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

.text-muted-inline {
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-xs);
}

.plugin-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    flex-shrink: 0;
}

.expand-icon {
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-xs);
    transition: transform var(--sp-duration-fast);
}
.plugin-card.is-open .expand-icon,
.plugin-card[data-open="true"] .expand-icon {
    transform: rotate(180deg);
}

.plugin-details {
    border-top: 1px solid var(--sp-border-subtle);
    padding: var(--sp-space-4);
}

/* ── plugin-tabs.hbs — detail rows ────────────────────────────── */
.plugin-tabs-container { min-width: 0; }

.plugin-tab-placeholder {
    padding: var(--sp-space-4);
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-sm);
    text-align: center;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-space-3);
    padding: var(--sp-space-3) 0;
    border-bottom: 1px solid var(--sp-border-subtle);
}
.detail-item:last-child { border-bottom: none; }

.detail-item-info { min-width: 0; flex: 1; }

.detail-item-name {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.detail-item-desc {
    margin-top: 2px;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

.detail-item-command {
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    flex-shrink: 0;
}

/* ── user-group.hbs / version-card.hbs ────────────────────────── */
.version-user-group { margin-bottom: var(--sp-space-5); }

.version-user-header { margin-bottom: var(--sp-space-3); }

.user-group-header-row {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
}

.user-avatar--circle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--sp-radius-full);
    background: var(--sp-accent-dim);
    color: var(--sp-accent);
    font-size: var(--sp-text-xs);
    font-weight: 700;
    text-transform: uppercase;
}

.user-group-name {
    font-size: var(--sp-text-base);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.user-group-meta {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.version-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-2);
}

.loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-space-6);
    color: var(--sp-text-tertiary);
}

/* ── role-checklist.hbs / entity-checklist.hbs ────────────────── */
.role-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2) var(--sp-space-4);
}

.role-checklist__label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    cursor: pointer;
}

.checklist-filter { margin-bottom: var(--sp-space-2); }

.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
    padding: var(--sp-space-1);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-sm);
    background: var(--sp-bg-surface);
}

/* ── plugin-install-guide.hbs ─────────────────────────────────── */
.install-guide { min-width: 0; }
.install-guide__title { margin: 0; }

.install-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-4);
}

.install-step {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: var(--sp-space-3);
    align-items: start;
}

.install-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--sp-radius-full);
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    font-weight: 700;
    font-size: var(--sp-text-sm);
}

.install-step-content { min-width: 0; }

.install-step__hint {
    margin: var(--sp-space-1) 0;
}

.install-copybox {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
}
.install-copybox--spaced { margin-top: var(--sp-space-2); }

.install-code {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    padding: var(--sp-space-2) var(--sp-space-3);
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-sm);
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-primary);
    white-space: nowrap;
}

/* ── models.hbs — stats-row (stat-card grid) ──────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-space-3);
    margin-bottom: var(--sp-space-5);
}

/* ── sparkline-card.hbs (stat-card + delta pill + sparkline) ──── */
.sparkline-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    padding: var(--sp-space-4);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 0 0.375rem 1.125rem 0;
    text-decoration: none;
    color: inherit;
}
a.sparkline-card:hover { border-color: var(--sp-border-strong); }

.sparkline-card--danger {
    border-color: color-mix(in oklch, var(--sp-danger) 45%, var(--sp-border-subtle));
    background: color-mix(in oklch, var(--sp-danger) 4%, var(--sp-bg-surface));
}
.sparkline-card--success {
    border-color: color-mix(in oklch, var(--sp-success) 45%, var(--sp-border-subtle));
    background: color-mix(in oklch, var(--sp-success) 4%, var(--sp-bg-surface));
}

.sparkline-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-2);
}

.sparkline-card__label {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
}

.sparkline-card__delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: var(--sp-text-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--sp-text-tertiary);
}
.sparkline-card__delta--good { color: var(--sp-success); }
.sparkline-card__delta--bad { color: var(--sp-danger); }
.sparkline-card__delta--neutral { color: var(--sp-text-tertiary); }
.sparkline-card__delta-arrow { line-height: 1; }

.sparkline-card__value {
    font-size: var(--sp-text-2xl, 1.5rem);
    font-weight: 700;
    color: var(--sp-text-primary);
    font-variant-numeric: tabular-nums;
}

.sparkline-card__subtitle {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.sparkline-card__chart {
    margin-top: var(--sp-space-2);
    height: 40px;
}

/* ── layout.hbs — global limit warning strip (hidden by default) ── */
.global-limit-warnings {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-2);
    margin: var(--sp-space-3) 0;
}
.global-limit-warnings:empty { display: none; }

/* ── transcript-turn.hbs — chat-bubble transcript rows ────────── */
.transcript-turn {
    display: block;
    padding: var(--sp-space-3) 0;
    border-bottom: 1px dashed var(--sp-border-subtle);
}
.transcript-turn:last-child { border-bottom: none; }

.transcript-turn__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.transcript-turn__role-pill {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--sp-text-secondary);
}
.transcript-turn__role-pill--user { color: var(--sp-accent); }
.transcript-turn__role-pill--assistant { color: var(--sp-section-users); }
.transcript-turn__role-pill--tool { color: var(--sp-warning); }

.transcript-turn__ordinal { color: var(--sp-text-tertiary); }
.transcript-turn__model { color: var(--sp-text-secondary); }
.transcript-turn__ts { color: var(--sp-text-tertiary); }
.transcript-turn__latency { color: var(--sp-text-tertiary); }

.transcript-turn__anomaly { color: var(--sp-warning); }

.transcript-turn__spacer { flex: 1; }

.transcript-turn__chain-link {
    color: var(--sp-accent);
    text-decoration: none;
    white-space: nowrap;
}
.transcript-turn__chain-link:hover { text-decoration: underline; }

.transcript-turn__bubble {
    margin-top: var(--sp-space-2);
}

.transcript-turn__content {
    font-size: var(--sp-text-sm);
    line-height: 1.55;
    color: var(--sp-text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}
.transcript-turn__content--redacted { color: var(--sp-text-primary); }
.transcript-turn__content--raw {
    margin-top: var(--sp-space-2);
    padding-top: var(--sp-space-2);
    border-top: 1px dashed var(--sp-border-subtle);
    color: var(--sp-text-secondary);
}

.transcript-turn__redaction-note {
    margin: var(--sp-space-1) 0 0;
    font-size: var(--sp-text-xs);
    color: var(--sp-warning);
}

.transcript-turn__tool-calls {
    list-style: none;
    margin: var(--sp-space-2) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
}

.transcript-turn__tool {
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-sm);
    background: var(--sp-bg-surface-raised);
    padding: var(--sp-space-1) var(--sp-space-2);
}
.transcript-turn__tool--error { border-color: color-mix(in oklch, var(--sp-danger) 40%, transparent); }

.transcript-turn__tool summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-space-2);
    cursor: pointer;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.transcript-turn__tool-name {
    color: var(--sp-text-primary);
    font-weight: 500;
}
.transcript-turn__tool-status {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.transcript-turn__tool--error .transcript-turn__tool-status { color: var(--sp-danger); }
.transcript-turn__tool-duration {
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.transcript-turn__tool-body {
    margin-top: var(--sp-space-2);
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
}
.transcript-turn__tool-body h5 {
    margin: var(--sp-space-1) 0 0;
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
}

}

@layer components {
.demo-help-box {
    display: block;
    background: var(--sp-bg-surface-gradient);
    border: 1px solid var(--sp-border-subtle);
    border-left: 3px solid var(--sp-accent);
    border-radius: var(--sp-radius-card-brand);
    margin: 0 var(--sp-space-4) var(--sp-space-6);
    box-shadow: var(--sp-shadow-card), var(--sp-shadow-inner-glow);
}

.demo-help-box__body,
.demo-help-box__footer {
    padding: 0 var(--sp-space-6);
}

.demo-help-box__body { padding-top: var(--sp-space-4); padding-bottom: var(--sp-space-3); }
.demo-help-box__docs-wrap { padding: 0 var(--sp-space-6) var(--sp-space-3); }
.demo-help-box__footer { padding-bottom: var(--sp-space-5); padding-top: var(--sp-space-3); }

.demo-help-box__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-3);
    flex-wrap: wrap;
    list-style: none;
    cursor: pointer;
    padding: var(--sp-space-4) var(--sp-space-6);
    user-select: none;
}

.demo-help-box__header::-webkit-details-marker { display: none; }

.demo-help-box__chevron {
    margin-left: auto;
    color: var(--sp-text-tertiary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
    transform: rotate(-90deg);
}

.demo-help-box[open] .demo-help-box__chevron {
    transform: rotate(0deg);
}

.demo-help-box[open] .demo-help-box__header {
    border-bottom: 1px solid var(--sp-border-subtle);
    padding-bottom: var(--sp-space-3);
}

.demo-help-box__badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sp-accent);
}

.demo-help-box__badge svg {
    flex-shrink: 0;
}

.demo-help-box__page {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--sp-space-2);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-pill, 999px);
    font-family: var(--sp-font-mono, ui-monospace, SFMono-Regular, monospace);
    font-size: var(--sp-text-2xs, 0.6875rem);
    color: var(--sp-text-tertiary);
    background: var(--sp-bg-surface);
}

.demo-help-box__body {
    max-width: 78ch;
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-base);
    line-height: 1.6;
}

.demo-help-box__body > :first-child { margin-top: 0; }
.demo-help-box__body > :last-child { margin-bottom: 0; }
.demo-help-box__body p { margin: 0 0 var(--sp-space-2); }
.demo-help-box__body strong { color: var(--sp-text-primary); font-weight: 600; }
.demo-help-box__body code {
    font-family: var(--sp-font-mono, ui-monospace, SFMono-Regular, monospace);
    font-size: 0.9em;
    padding: 1px 4px;
    border-radius: var(--sp-radius-sm, 4px);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
}

.demo-help-box__docs {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    align-self: flex-start;
    padding: var(--sp-space-2) var(--sp-space-3);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-pill, 999px);
    color: var(--sp-accent);
    font-weight: 500;
    font-size: var(--sp-text-sm);
    text-decoration: none;
    background: var(--sp-bg-surface);
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.demo-help-box__docs:hover {
    color: var(--sp-accent-hover);
    border-color: var(--sp-accent);
    background: var(--sp-bg-surface-raised, var(--sp-bg-surface));
}

.demo-help-box__docs svg { flex-shrink: 0; }

.demo-help-box__footer {
    margin: 0;
    padding-top: var(--sp-space-3);
    border-top: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    line-height: 1.5;
}

.demo-help-box__footer a {
    color: var(--sp-accent);
    font-weight: 500;
}

.demo-help-box__footer a:hover {
    color: var(--sp-accent-hover);
}
}

@layer components {

.confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--sp-overlay-medium);
    backdrop-filter: blur(4px);
    z-index: var(--sp-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--sp-duration-normal) var(--sp-ease-out);
}

.confirm-dialog {
    background: var(--sp-bg-surface-overlay);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-brand);
    padding: var(--sp-space-7);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--sp-shadow-float);
    animation: dialogIn var(--sp-duration-normal) var(--sp-ease-out);
    color: var(--sp-text-primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialogIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.btn-actions-trigger,
.actions-trigger {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    color: var(--sp-text-secondary);
    border-radius: var(--sp-radius-sm);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--sp-text-md);
    line-height: 1;
    letter-spacing: 2px;
    transition: background var(--sp-duration-fast) var(--sp-ease-in-out),
                border-color var(--sp-duration-fast) var(--sp-ease-in-out),
                color var(--sp-duration-fast) var(--sp-ease-in-out);
}

.btn-actions-trigger:hover,
.btn-actions-trigger.active,
.actions-trigger:hover,
.actions-menu.open .actions-trigger {
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-strong);
    color: var(--sp-text-primary);
}

.btn-actions-trigger:focus-visible,
.actions-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px var(--sp-accent);
}

.actions-menu {
    position: relative;
    display: inline-block;
}

.actions-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--sp-space-1);
    background: var(--sp-bg-surface-overlay);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-inner-brand);
    box-shadow: var(--sp-shadow-float);
    z-index: var(--sp-z-dropdown);
    min-width: 140px;
    padding: var(--sp-space-1) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--sp-duration-fast) var(--sp-ease-in-out),
                visibility var(--sp-duration-fast),
                transform var(--sp-duration-fast) var(--sp-ease-in-out);
}

.actions-menu.open .actions-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.actions-item {
    display: block;
    width: 100%;
    padding: var(--sp-space-2) var(--sp-space-4);
    background: transparent;
    border: none;
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--sp-duration-fast), color var(--sp-duration-fast);
}

.actions-item:hover,
.actions-item:focus-visible {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-primary);
    outline: none;
}

.actions-item-danger {
    color: var(--sp-danger);
}

.actions-item-danger:hover {
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
}

.sp-env-dialog {
    width: 560px;
    max-width: 90vw;
}

.sp-env-title {
    margin: 0 0 var(--sp-space-4);
}

.sp-env-scroll {
    max-height: 60vh;
    overflow-y: auto;
}

.sp-env-actions {
    display: flex;
    gap: var(--sp-space-3);
    justify-content: flex-end;
    margin-top: var(--sp-space-4);
}

.sp-env-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-space-6);
    color: var(--sp-text-tertiary);
}

.sp-env-save-success {
    background: var(--sp-success);
    border-color: var(--sp-success);
}

/* Native <dialog> modal (management-departments create form). */
.dialog {
    padding: 0;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-corners-lg, var(--sp-radius-card-brand));
    background: var(--sp-bg-surface-overlay);
    color: var(--sp-text-primary);
    box-shadow: var(--sp-shadow-float);
    max-width: min(480px, 92vw);
    width: 100%;
}

.dialog::backdrop {
    background: var(--sp-overlay-medium, oklch(0 0 0 / 0.4));
    backdrop-filter: blur(4px);
}

.dialog-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
    padding: var(--sp-space-6);
}

.dialog-form h3 {
    margin: 0;
    font-size: var(--sp-text-lg);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.dialog-form label {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-secondary);
}

.dialog-form input,
.dialog-form textarea {
    font: inherit;
    font-weight: 400;
    padding: var(--sp-space-2) var(--sp-space-3);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    color: var(--sp-text-primary);
}

.dialog-form input:focus,
.dialog-form textarea:focus {
    outline: none;
    border-color: var(--sp-accent);
    box-shadow: 0 0 0 2px var(--sp-accent-dim);
}

.dialog-form menu {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-space-2);
    margin: var(--sp-space-2) 0 0;
    padding: 0;
}

@media (prefers-reduced-motion: reduce) {
    .confirm-overlay,
    .confirm-dialog {
        animation: none;
    }
    .actions-dropdown {
        transition: none;
    }
}

}

@layer components {
.chain-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--sp-z-modal-backdrop, 1400);
    display: block;
}

.chain-drawer[hidden] {
    display: none;
}

.chain-drawer__overlay {
    position: absolute;
    inset: 0;
    background: light-dark(oklch(0.20 0.01 50 / 0.32), oklch(0.05 0 0 / 0.55));
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.chain-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(640px, 100vw);
    background: var(--sp-bg-surface);
    border-left: 1px solid var(--sp-border-default);
    box-shadow: -8px 0 32px -12px var(--sp-shadow-color, oklch(0 0 0 / 0.18));
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(0);
    animation: chain-drawer-slide-in 180ms ease-out;
}

@keyframes chain-drawer-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.chain-drawer__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--sp-border-default);
    background: var(--sp-bg-surface-raised);
    position: sticky;
    top: 0;
    z-index: 1;
}

.chain-drawer__header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.chain-drawer__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--sp-text-primary);
}

.chain-drawer__close {
    background: transparent;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm, 6px);
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--sp-text-muted);
}

.chain-drawer__close:hover {
    color: var(--sp-text-primary);
    border-color: var(--sp-border-strong);
}

.chain-drawer__ids {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.chain-drawer__id-label {
    color: var(--sp-text-muted);
    font-weight: 500;
}

.chain-drawer__id {
    font-family: var(--sp-font-mono);
    color: var(--sp-text-primary);
    background: var(--sp-bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--sp-radius-sm, 4px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 22ch;
}

.chain-drawer__copy {
    background: transparent;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm, 4px);
    padding: 0.125rem 0.375rem;
    cursor: pointer;
    color: var(--sp-text-muted);
    font-size: 0.75rem;
}

.chain-drawer__copy:hover {
    color: var(--sp-text-primary);
}

.chain-drawer__status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.chain-drawer__pill {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--sp-bg-tertiary);
    color: var(--sp-text-muted);
    border: 1px solid var(--sp-border-default);
}

.chain-drawer__pill--allow {
    background: color-mix(in oklch, var(--sp-success) 12%, transparent);
    color: var(--sp-success);
    border-color: color-mix(in oklch, var(--sp-success) 35%, transparent);
}

.chain-drawer__pill--deny {
    background: color-mix(in oklch, var(--sp-danger) 12%, transparent);
    color: var(--sp-danger);
    border-color: color-mix(in oklch, var(--sp-danger) 35%, transparent);
}

.chain-drawer__identity {
    color: var(--sp-text-muted);
}

.chain-drawer__totals {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 0.75rem 0 0;
    font-size: 0.75rem;
}

.chain-drawer__totals > div {
    background: var(--sp-bg-tertiary);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm, 6px);
    padding: 0.375rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.chain-drawer__totals dt {
    color: var(--sp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.6875rem;
}

.chain-drawer__totals dd {
    margin: 0;
    color: var(--sp-text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.chain-drawer__stepper {
    list-style: none;
    margin: 0;
    padding: 0.75rem 1.25rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    border-bottom: 1px solid var(--sp-border-default);
}

.chain-drawer__stage {
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm, 6px);
    padding: 0.5rem 0.625rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--sp-bg-tertiary);
    font-size: 0.75rem;
}

.chain-drawer__stage-name {
    font-weight: 600;
    color: var(--sp-text-primary);
}

.chain-drawer__stage-state {
    color: var(--sp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.6875rem;
}

.chain-drawer__stage--pass {
    background: color-mix(in oklch, var(--sp-success) 8%, var(--sp-bg-surface));
    border-color: color-mix(in oklch, var(--sp-success) 35%, transparent);
}

.chain-drawer__stage--pass .chain-drawer__stage-state {
    color: var(--sp-success);
}

.chain-drawer__stage--fail {
    background: color-mix(in oklch, var(--sp-danger) 10%, var(--sp-bg-surface));
    border-color: color-mix(in oklch, var(--sp-danger) 40%, transparent);
}

.chain-drawer__stage--fail .chain-drawer__stage-state {
    color: var(--sp-danger);
}

.chain-drawer__stage--skipped {
    opacity: 0.55;
}

.chain-drawer__stage-detail {
    color: var(--sp-text-muted);
    font-size: 0.6875rem;
    line-height: 1.3;
    word-break: break-word;
}

.chain-drawer__section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--sp-border-default);
}

.chain-drawer__section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--sp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chain-drawer__transcript {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 240px;
    overflow-y: auto;
}

.chain-drawer__events {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.chain-drawer__event {
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm, 6px);
    padding: 0.5rem 0.625rem;
    background: var(--sp-bg-tertiary);
    font-size: 0.8125rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
    align-items: baseline;
}

.chain-drawer__event-type {
    font-family: var(--sp-font-mono);
    color: var(--sp-accent);
    font-size: 0.75rem;
}

.chain-drawer__event-tool {
    color: var(--sp-text-primary);
}

.chain-drawer__event-time {
    color: var(--sp-text-muted);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
}

.chain-drawer__requests {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.chain-drawer__requests th,
.chain-drawer__requests td {
    text-align: left;
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--sp-border-default);
}

.chain-drawer__requests th {
    color: var(--sp-text-muted);
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chain-drawer__requests td {
    font-variant-numeric: tabular-nums;
    color: var(--sp-text-primary);
}

.chain-drawer__empty {
    color: var(--sp-text-muted);
    font-size: 0.8125rem;
    margin: 0;
    padding: 0.5rem 0;
}

.chain-drawer__raw {
    padding: 1rem 1.25rem;
}

.chain-drawer__raw summary {
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--sp-text-muted);
}

.chain-drawer__raw[open] summary {
    color: var(--sp-text-primary);
    margin-bottom: 0.5rem;
}

.chain-drawer__raw-tree {
    margin-top: 0.5rem;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm, 6px);
    padding: 0.5rem;
    background: var(--sp-bg-tertiary);
}

.chain-drawer__error {
    padding: 1rem 1.25rem;
    color: var(--sp-danger);
    font-size: 0.8125rem;
}

@media (max-width: 720px) {
    .chain-drawer__panel {
        width: 100vw;
    }
    .chain-drawer__totals {
        grid-template-columns: repeat(2, 1fr);
    }
    .chain-drawer__stepper {
        grid-template-columns: repeat(2, 1fr);
    }
}
}

@layer components {

.sp-dropdown-portal {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    z-index: var(--sp-z-dropdown);
    pointer-events: none;
}

.sp-dropdown-menu {
    position: fixed;
    left: auto;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    background: var(--sp-bg-surface-overlay);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
    box-shadow: var(--sp-shadow-lg);
    min-width: 140px;
    padding: var(--sp-space-1) 0;
    z-index: var(--sp-z-dropdown);
}

}

/* Identity filter ribbon — multi-select dropdown groups + active chips.
   Markup: partials/components/identity-filter-ribbon.hbs + filter-ribbon-group.hbs */

@layer components {

/* The ribbon owns a stacking context above the page content. Without it the
   open dropdown panel competes with the stat grid and table that follow it in
   .admin-main (position:relative; contain:layout) and paints underneath them. */
.filter-ribbon {
    position: relative;
    z-index: var(--sp-z-panel);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-2);
    margin-bottom: var(--sp-space-4);
}

.filter-ribbon__groups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-2);
}

.filter-ribbon__group {
    position: relative;
}

/* An open group outranks its closed siblings, so two open panels overlap in
   the order the reader opened them rather than by DOM position. */
.filter-ribbon__group[open] {
    z-index: 1;
}

.filter-ribbon__group-summary {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: var(--sp-space-1) var(--sp-space-3);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: border-color var(--sp-duration-fast), color var(--sp-duration-fast);
}

.filter-ribbon__group-summary::-webkit-details-marker {
    display: none;
}

.filter-ribbon__group-summary:hover {
    color: var(--sp-text-primary);
    border-color: var(--sp-border-strong, var(--sp-border-subtle));
}

.filter-ribbon__group[open] > .filter-ribbon__group-summary {
    color: var(--sp-text-primary);
    border-color: var(--sp-accent);
}

.filter-ribbon__group-caret {
    font-size: 0.6em;
    transition: transform var(--sp-duration-fast);
}

.filter-ribbon__group[open] .filter-ribbon__group-caret {
    transform: rotate(180deg);
}

.filter-ribbon__group-panel {
    position: absolute;
    top: calc(100% + var(--sp-space-1));
    left: 0;
    z-index: var(--sp-z-dropdown);
    min-width: 240px;
    max-width: 320px;
    max-height: 320px;
    overflow-y: auto;
    padding: var(--sp-space-2);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-corners-md, var(--sp-radius-md));
    box-shadow: var(--sp-shadow-lg);
}

.filter-ribbon__group-search {
    width: 100%;
    margin-bottom: var(--sp-space-2);
    padding: var(--sp-space-1) var(--sp-space-2);
    background: var(--sp-bg-input, var(--sp-bg-surface-raised));
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-sm);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
}

.filter-ribbon__group-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.filter-ribbon__group-item {
    margin: 0;
}

.filter-ribbon__option {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-1) var(--sp-space-2);
    border-radius: var(--sp-radius-sm);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    cursor: pointer;
}

.filter-ribbon__option:hover {
    background: color-mix(in oklch, var(--sp-accent) 6%, transparent);
    color: var(--sp-text-primary);
}

.filter-ribbon__option-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-ribbon__option-count {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.filter-ribbon__group--empty {
    padding: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
}

.filter-ribbon__group-title {
    font-size: var(--sp-text-sm);
    color: inherit;
}

.filter-ribbon__group--empty {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
}

.filter-ribbon__group-empty-text {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-style: italic;
}

.filter-ribbon__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
}

.filter-ribbon__apply {
    padding: var(--sp-space-1) var(--sp-space-3);
    background: var(--sp-accent);
    border: 1px solid var(--sp-accent);
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-on-accent, #fff);
    cursor: pointer;
    transition: filter var(--sp-duration-fast);
}

.filter-ribbon__apply:hover {
    filter: brightness(1.08);
}

.filter-ribbon__clear {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    text-decoration: none;
}

.filter-ribbon__clear:hover {
    color: var(--sp-text-primary);
    text-decoration: underline;
}

.filter-ribbon__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-1);
    width: 100%;
    margin: var(--sp-space-1) 0 0;
    padding: 0;
    list-style: none;
}

.filter-ribbon__chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: 2px var(--sp-space-2);
    background: color-mix(in oklch, var(--sp-accent) 8%, var(--sp-bg-surface));
    border: 1px solid color-mix(in oklch, var(--sp-accent) 30%, var(--sp-border-subtle));
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-xs);
}

.filter-ribbon__chip-group {
    color: var(--sp-text-tertiary);
}

.filter-ribbon__chip-value {
    color: var(--sp-text-primary);
    font-weight: 600;
    max-width: 18ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-ribbon__chip-remove {
    color: var(--sp-text-tertiary);
    text-decoration: none;
    font-weight: 700;
    line-height: 1;
    padding: 0 2px;
}

.filter-ribbon__chip-remove:hover {
    color: var(--sp-danger);
}

}

@layer components {

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-space-4);
}

.form-group-wide {
    grid-column: 1 / -1;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2) var(--sp-space-4);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    font-size: var(--sp-text-sm);
    cursor: pointer;
}

.toolbar {
    display: flex;
    gap: var(--sp-space-3);
    align-items: flex-end;
    margin-bottom: var(--sp-space-4);
    flex-wrap: wrap;
}

.search-input {
    width: 100%;
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    padding: var(--sp-space-2) var(--sp-space-4);
    color: var(--sp-text-primary);
    font-size: var(--sp-text-base);
    font-family: inherit;
    outline: none;
    transition: border-color var(--sp-duration-fast), box-shadow var(--sp-duration-fast);
}

.search-input:focus-visible {
    border-color: var(--sp-accent);
    outline: 2px solid var(--sp-accent-dim);
    outline-offset: -1px;
}

.search-input::placeholder {
    color: var(--sp-text-disabled);
}

.search-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.filter-select {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    padding: var(--sp-space-2) var(--sp-space-4);
    color: var(--sp-text-primary);
    font-size: var(--sp-text-sm);
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color var(--sp-duration-fast);
}

.filter-select:focus-visible {
    border-color: var(--sp-accent);
    outline: 2px solid var(--sp-accent-dim);
    outline-offset: -1px;
}

.filter-select option {
    background: var(--sp-bg-surface-overlay);
    color: var(--sp-text-primary);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.filter-label {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    color: var(--sp-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

.filter-field {
    display: inline-flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.filter-field__label {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    color: var(--sp-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

.filter-field .filter-select {
    min-width: 9rem;
}

.audit-toolbar__notice {
    margin: -0.5rem 0 0.5rem;
}

/* Chip filter strip — segmented pill buttons (catalog, marketplace).
   Mirrors the time-range preset pills; .active is the selected state. */
.filter-chips {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-2);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: var(--sp-space-1) var(--sp-space-3);
    border-radius: var(--sp-radius-full);
    border: 1px solid var(--sp-border-default);
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    font-family: inherit;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--sp-duration-fast), color var(--sp-duration-fast),
                border-color var(--sp-duration-fast);
}

.chip:hover {
    color: var(--sp-text-primary);
    border-color: var(--sp-border-strong);
}

.chip.active {
    background: var(--sp-accent);
    border-color: var(--sp-accent);
    color: var(--sp-text-on-accent, #fff);
    font-weight: 600;
}

}

@layer components {

.install-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    margin-right: var(--sp-space-3);
}

.install-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
    color: var(--sp-text-secondary);
    cursor: pointer;
    transition: background var(--sp-duration-fast) var(--sp-ease-out),
                border-color var(--sp-duration-fast) var(--sp-ease-out),
                color var(--sp-duration-fast) var(--sp-ease-out);
}

.plugin-counter {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 0.3125rem;
    font-size: var(--sp-text-xs);
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    color: var(--sp-text-on-accent);
    background: var(--sp-accent);
    border-radius: var(--sp-radius-full);
    pointer-events: none;
}

.install-trigger:hover,
.install-menu.open .install-trigger {
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-strong);
    color: var(--sp-text-primary);
}

.install-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px var(--sp-accent);
}

.install-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--sp-space-2);
    width: 380px;
    background: var(--sp-bg-surface-overlay);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-inner-brand);
    box-shadow: var(--sp-shadow-float);
    z-index: var(--sp-z-dropdown);
    padding: var(--sp-space-4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--sp-duration-fast) var(--sp-ease-out),
                visibility var(--sp-duration-fast),
                transform var(--sp-duration-fast) var(--sp-ease-out);
}

.install-menu.open .install-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.install-dropdown-header {
    margin-bottom: var(--sp-space-3);
}

.install-dropdown-title {
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
    margin-bottom: var(--sp-space-2);
}

.install-dropdown .install-widget-stats {
    display: flex;
    gap: var(--sp-space-3);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    flex-wrap: wrap;
}

.install-dropdown .install-stat strong {
    color: var(--sp-text-primary);
}

.install-dropdown-body {
    padding: var(--sp-space-2);
}

.install-tab-content {
    padding: var(--sp-space-3) 0;
}

.install-tab-hint {
    margin: 0 0 var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

}

@layer components {

.json-tree {
    --json-tree-indent: 1.25rem;
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
    line-height: 1.55;
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand, 8px);
    padding: var(--sp-space-3, 0.75rem);
    overflow: auto;
    max-height: 60vh;
}

.json-tree__node {
    display: block;
    padding-left: calc(var(--depth, 0) * var(--json-tree-indent));
    position: relative;
    white-space: pre;
}

.json-tree__row {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    max-width: 100%;
}

.json-tree__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border: none;
    background: transparent;
    color: var(--sp-text-tertiary);
    cursor: pointer;
    padding: 0;
    font: inherit;
    user-select: none;
    flex-shrink: 0;
}

.json-tree__toggle:hover {
    color: var(--sp-accent);
}

.json-tree__toggle::before {
    content: "\25BE"; /* down triangle (expanded) */
    font-size: 0.75rem;
    line-height: 1;
    transition: transform 120ms ease;
}

.json-tree__node.is-collapsed > .json-tree__row > .json-tree__toggle::before {
    transform: rotate(-90deg);
}

.json-tree__toggle--leaf {
    visibility: hidden;
}

.json-tree__key {
    color: var(--sp-section-plugins, var(--sp-text-secondary));
    font-weight: 600;
}

.json-tree__key::after {
    content: ":";
    color: var(--sp-text-tertiary);
    margin-right: 0.35rem;
    font-weight: 400;
}

.json-tree__index {
    color: var(--sp-text-tertiary);
    font-weight: 500;
}

.json-tree__index::after {
    content: ":";
    margin-right: 0.35rem;
    font-weight: 400;
}

.json-tree__punct {
    color: var(--sp-text-tertiary);
}

.json-tree__value {
    word-break: break-all;
}

.json-tree__value--string {
    color: var(--sp-success, #2a7);
}

.json-tree__value--number {
    color: var(--sp-section-plugins, #58c);
}

.json-tree__value--bool {
    color: var(--sp-warning, #c80);
    font-weight: 600;
}

.json-tree__value--null {
    color: var(--sp-text-tertiary);
    font-style: italic;
}

.json-tree__summary {
    color: var(--sp-text-tertiary);
    font-style: italic;
    margin-left: 0.25rem;
}

.json-tree__path-copy {
    border: none;
    background: transparent;
    color: var(--sp-text-tertiary);
    cursor: pointer;
    padding: 0 0.25rem;
    font: inherit;
    font-size: 0.75rem;
    line-height: 1;
    margin-left: 0.35rem;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}

.json-tree__row:hover > .json-tree__path-copy,
.json-tree__path-copy:focus-visible {
    opacity: 1;
}

.json-tree__path-copy:hover {
    color: var(--sp-accent);
    background: var(--sp-accent-dim);
}

.json-tree__path-copy.is-copied {
    color: var(--sp-success);
    opacity: 1;
}

.json-tree__expand-more {
    border: none;
    background: transparent;
    color: var(--sp-accent);
    cursor: pointer;
    font: inherit;
    font-size: var(--sp-text-xs);
    padding: 0.15rem 0.5rem;
    margin: 0.25rem 0 0.25rem calc(var(--depth, 0) * var(--json-tree-indent) + 1.25rem);
    border-radius: 4px;
}

.json-tree__expand-more:hover {
    background: var(--sp-accent-dim);
}

.json-tree__error {
    color: var(--sp-danger);
    font-style: italic;
}

.json-tree__circular {
    color: var(--sp-warning);
    font-style: italic;
}

}

@layer components {

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: var(--sp-accent-dim);
}

.detail-header {
    margin-bottom: var(--sp-space-7);
    display: flex;
    align-items: center;
    gap: var(--sp-space-4);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--sp-border-default);
    border-top-color: var(--sp-accent);
    border-radius: var(--sp-radius-full);
    animation: spin var(--sp-duration-slow) linear infinite;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-space-3);
    padding: var(--sp-space-12);
    color: var(--sp-text-tertiary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.actions-popup {
    position: fixed;
    background: var(--sp-bg-surface-overlay);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-inner-brand);
    box-shadow: var(--sp-shadow-float);
    z-index: var(--sp-z-dropdown);
    min-width: 180px;
    padding: var(--sp-space-1) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--sp-duration-fast) var(--sp-ease-in-out),
                visibility var(--sp-duration-fast),
                transform var(--sp-duration-fast) var(--sp-ease-in-out);
}

.actions-popup.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.actions-popup-item {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    width: 100%;
    padding: var(--sp-space-2) var(--sp-space-4);
    background: transparent;
    border: none;
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    min-height: 44px;
    transition: background var(--sp-duration-fast), color var(--sp-duration-fast);
    appearance: none;
}

.actions-popup-item:hover,
.actions-popup-item:focus-visible {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-primary);
    outline: none;
}

.actions-popup-item .popup-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.actions-popup-item--danger {
    color: var(--sp-danger);
}

.actions-popup-item--danger:hover {
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
}

.actions-popup-separator {
    height: 1px;
    background: var(--sp-border-subtle);
    margin: var(--sp-space-1) 0;
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
    }
}

}

@layer components {

.skill-file-category {
    font-size: var(--sp-text-xs);
    font-weight: 700;
    color: var(--sp-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--sp-space-2) var(--sp-space-3);
    margin-top: var(--sp-space-2);
}

.skill-file-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--sp-space-2) var(--sp-space-3);
    cursor: pointer;
    border-radius: var(--sp-radius-sm);
    color: var(--sp-text-primary);
    transition: background var(--sp-duration-fast) var(--sp-ease-in-out);
}

.skill-file-item:hover {
    background: var(--sp-bg-surface-raised);
}

.skill-file-item.selected {
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
}

.skill-file-name {
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-sm);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.skill-file-lang {
    flex-shrink: 0;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    padding-left: var(--sp-space-3);
}

.skill-file-item.selected .skill-file-lang {
    color: inherit;
    opacity: 0.7;
}

.code-inline {
    background: var(--sp-bg-surface-raised);
    padding: 0.125rem var(--sp-space-2);
    border-radius: var(--sp-radius-xs);
    font-size: var(--sp-text-xs);
}

/* Preformatted payload block — JSON tool input/results, prompt bodies. Had no
   base rule, so every `<pre class="code-block">` rendered as a bare `<pre>`;
   page-level rules in 18/21 only add scroll caps on top of this. */
.code-block {
    margin: 0;
    padding: var(--sp-space-3);
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-md);
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
    line-height: 1.5;
    color: var(--sp-text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
}

.section-footer {
    text-align: center;
    margin-top: var(--sp-space-3);
}

.section-footer a {
    color: var(--sp-accent-blue);
}

.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--sp-space-4);
}

.dept-card-title {
    font-size: var(--sp-text-lg);
    font-weight: 600;
    margin-bottom: var(--sp-space-4);
}

.stats-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-space-3);
}

.dept-top-user {
    margin-top: var(--sp-space-3);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

.metadata-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-space-2) var(--sp-space-4);
    font-size: var(--sp-text-sm);
    margin-bottom: var(--sp-space-3);
}

.detail-content {
    padding: var(--sp-space-3) var(--sp-space-4);
    background: var(--sp-bg-surface-raised);
    border-top: 1px solid var(--sp-border-primary);
}

.detail-summary {
    cursor: pointer;
    font-size: var(--sp-text-sm);
    font-weight: 600;
    margin-bottom: var(--sp-space-2);
}

.detail-pre {
    font-size: var(--sp-text-xs);
    background: var(--sp-bg-surface);
    padding: var(--sp-space-3);
    border-radius: var(--sp-radius-sm);
    overflow-x: auto;
    max-height: 300px;
}

.clickable {
    cursor: pointer;
}

.expand-chevron {
    transition: transform var(--sp-duration-normal);
    display: inline-block;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.search-narrow {
    width: 260px;
}
.cell-no-pad {
    padding: 0;
}

.col-chevron {
    width: 32px;
}

.form-hint {
    font-weight: 400;
    color: var(--sp-text-tertiary);
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-3);
    width: auto;
    height: auto;
}

.toggle-label-text {
    margin: 0;
    white-space: nowrap;
}

/* Toggle switch (form-group checkbox, toggle-switch partial).
   The checkbox is visually hidden; .toggle-slider is the track + knob. */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-3);
    cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
    background: color-mix(in oklch, var(--sp-text-tertiary) 25%, transparent);
    border-radius: var(--sp-radius-full);
    transition: background var(--sp-duration-fast) var(--sp-ease-out);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--sp-toggle-knob);
    border-radius: var(--sp-radius-full);
    box-shadow: var(--sp-shadow-xs);
    transition: transform var(--sp-duration-fast) var(--sp-ease-out);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--sp-accent);
}
.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(20px);
}
.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--sp-accent);
    outline-offset: 2px;
}

}

@layer components {
.usage-limits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-space-3);
    margin-bottom: var(--sp-space-4);
}

.usage-limit-item {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    padding: var(--sp-space-3);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
}

.usage-limit-item--warning {
    border-color: color-mix(in oklch, var(--sp-warning) 40%, transparent);
}

.usage-limit-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.usage-limit-label {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.usage-limit-value {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    font-variant-numeric: tabular-nums;
}

.usage-limit-pct {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    font-weight: 600;
}

.usage-limit-bar {
    height: 6px;
    background: var(--sp-bg-surface-raised);
    border-radius: var(--sp-radius-xs);
    overflow: hidden;
}

.usage-limit-fill {
    height: 100%;
    background: var(--sp-success);
    border-radius: var(--sp-radius-xs);
    transition: width 0.3s ease;
}

.usage-limit-fill--danger {
    background: var(--sp-danger);
}

.rank-tier-1 { background: var(--sp-rank-tier-1-bg); color: var(--sp-text-on-accent); }
.rank-tier-2 { background: var(--sp-rank-tier-2-bg); color: var(--sp-text-on-accent); }
.rank-tier-3 { background: var(--sp-rank-tier-3-bg); color: var(--sp-text-on-accent); }
.rank-tier-4 { background: var(--sp-rank-tier-4-bg); color: var(--sp-text-on-accent); }
.rank-tier-5 { background: var(--sp-rank-tier-5-bg); color: var(--sp-text-on-accent); }

.rank-ladder {
    margin-bottom: var(--sp-space-4);
}

.rank-ladder-wrapper {
    position: relative;
}

.rank-ladder-title {
    font-size: var(--sp-text-md);
    font-weight: 700;
    color: var(--sp-text-primary);
    margin: 0 0 var(--sp-space-3);
}

.rank-ladder-section {
    display: flex;
    gap: var(--sp-space-2);
    align-items: center;
    margin-bottom: var(--sp-space-3);
}

.rank-ladder-level-label {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.rank-ladder-nav,
.rank-ladder-nav--right {
    display: flex;
    gap: var(--sp-space-1);
}

.rank-ladder__step {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-2) var(--sp-space-3);
    border-radius: var(--sp-radius-sm);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    font-size: var(--sp-text-sm);
}

.rank-ladder__step--current {
    border-color: var(--sp-accent);
    background: color-mix(in oklch, var(--sp-accent) 8%, var(--sp-bg-surface));
}

.rank-ladder__step-badge {
    width: 24px;
    height: 24px;
    border-radius: var(--sp-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.625rem;
    color: var(--sp-text-on-accent);
    flex-shrink: 0;
}

.rank-ladder__step-name {
    font-weight: 600;
    color: var(--sp-text-primary);
}

.rank-ladder__step-xp {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    margin-left: auto;
}
}

@layer components {
.setup-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: var(--sp-radius-full);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.setup-badge--complete {
    background: color-mix(in oklch, var(--sp-success) 15%, transparent);
    color: var(--sp-success);
}

.setup-badge--current {
    background: color-mix(in oklch, var(--sp-accent) 15%, transparent);
    color: var(--sp-accent);
}

.setup-phase-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-space-4);
    margin-bottom: var(--sp-space-2);
}

.setup-phase-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--sp-text-sm);
    font-weight: 500;
    color: var(--sp-accent);
    text-decoration: none;
    transition: gap 0.15s ease;
}

.setup-phase-link:hover {
    gap: 0.5rem;
    text-decoration: underline;
}

.setup-phase-action {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
    text-decoration: none;
    padding: var(--sp-space-1) var(--sp-space-3);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-sm);
    background: var(--sp-bg-surface);
    transition: border-color 0.15s ease, gap 0.15s ease;
}

.setup-phase-action:hover {
    border-color: var(--sp-accent);
    gap: 0.5rem;
}
@media (max-width: 640px) {
    .setup-page {
        padding: var(--sp-space-4) var(--sp-space-2);
    }

    .setup-phase-indicator {
        width: 2rem;
    }

    .setup-phase-number {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }

    .setup-phase-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}
}

@layer components {
.setup-page {
    max-width: 48rem;
    margin: 0 auto;
    padding: var(--sp-space-6) var(--sp-space-4);
}

.setup-hero {
    margin-bottom: var(--sp-space-8);
}

.setup-hero h2 {
    font-size: var(--sp-text-xl);
    font-weight: 700;
    margin: 0 0 var(--sp-space-2);
    color: var(--sp-text-primary);
}

.setup-hero p {
    color: var(--sp-text-secondary);
    line-height: 1.6;
    margin: 0;
}

.setup-stepper {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.setup-phase {
    display: flex;
    gap: var(--sp-space-4);
    position: relative;
}

.setup-phase-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 2.5rem;
}

.setup-phase-number {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--sp-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--sp-text-sm);
    flex-shrink: 0;
    border: 2px solid var(--sp-border-default);
    background: var(--sp-bg-surface);
    color: var(--sp-text-secondary);
    transition: all 0.2s ease;
}

.setup-phase--complete .setup-phase-number {
    background: var(--sp-success);
    border-color: var(--sp-success);
    color: var(--sp-text-on-accent);
}

.setup-phase--current .setup-phase-number {
    background: var(--sp-accent);
    border-color: var(--sp-accent);
    color: var(--sp-text-on-accent);
}

.setup-phase-connector {
    width: 2px;
    flex: 1;
    min-height: 1.5rem;
    background: var(--sp-border-default);
    transition: background 0.2s ease;
}

.setup-phase--complete .setup-phase-connector {
    background: var(--sp-success);
}

.setup-phase-content {
    padding-bottom: var(--sp-space-6);
    flex: 1;
    min-width: 0;
}

.setup-phase-header {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    margin-bottom: var(--sp-space-1);
}

.setup-phase-content h3 {
    font-size: var(--sp-text-base);
    font-weight: 600;
    margin: 0;
    color: var(--sp-text-primary);
}

.setup-phase--upcoming .setup-phase-content h3 {
    color: var(--sp-text-secondary);
}

.setup-phase-content p {
    color: var(--sp-text-secondary);
    line-height: 1.5;
    margin: 0 0 var(--sp-space-2);
    font-size: var(--sp-text-sm);
}
}

/* Core styling for the shared stat-card partial
   (partials/components/stat-card.hbs) and its grid wrappers. Visual language
   matches .kpi-card (17-contexts.css): branded corner radius, surface card. */

@layer components {

.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    padding: var(--sp-space-4);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 0 0.375rem 1.125rem 0;
}

/* A stat card that is also a filter (its number and the rows it counts are the
   same thing) reads as a card, not a link — the affordance is the hover lift. */
.stat-card--link {
    text-decoration: none;
    color: inherit;
    transition: border-color var(--sp-duration-fast), transform var(--sp-duration-fast),
        box-shadow var(--sp-duration-fast);
}

.stat-card--link:hover {
    border-color: var(--sp-accent);
    transform: translateY(-1px);
    box-shadow: var(--sp-shadow-sm, 0 1px 3px rgb(0 0 0 / 0.08));
}

.stat-card--link:focus-visible {
    outline: 2px solid var(--sp-accent);
    outline-offset: 2px;
}

.stat-card--link.is-active {
    border-color: var(--sp-accent);
    box-shadow: inset 0 0 0 1px var(--sp-accent);
}

.stat-card .label {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
}

.stat-card .value {
    font-size: var(--sp-text-2xl, 1.5rem);
    font-weight: 700;
    color: var(--sp-text-primary);
}

.stat-card .kpi-subtitle {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.stat-card.success {
    border-color: color-mix(in oklch, var(--sp-success) 45%, var(--sp-border-subtle));
    background: color-mix(in oklch, var(--sp-success) 4%, var(--sp-bg-surface));
}

.stat-card.success .value {
    color: var(--sp-success-strong, var(--sp-success));
}

.stat-card.danger {
    border-color: color-mix(in oklch, var(--sp-danger) 45%, var(--sp-border-subtle));
    background: color-mix(in oklch, var(--sp-danger) 4%, var(--sp-bg-surface));
}

.stat-card.danger .value {
    color: var(--sp-danger-strong, var(--sp-danger));
}

.stat-card.warning {
    border-color: color-mix(in oklch, var(--sp-warning) 45%, var(--sp-border-subtle));
    background: color-mix(in oklch, var(--sp-warning) 4%, var(--sp-bg-surface));
}

.stats-grid-4col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-space-3);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-space-3);
    margin-bottom: var(--sp-space-5);
}

.stats-grid-3col,
.stats-grid-4col {
    margin-bottom: var(--sp-space-5);
}

@media (max-width: 900px) {
    .stats-grid-3col { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .stats-grid-4col { grid-template-columns: repeat(2, 1fr); }
}

}

@layer components {

/* `flex-shrink: 0` is load-bearing wherever the bar is a direct child of a
   column flex container, as it is on the admin pages: `overflow-x` other than
   `visible` resolves this element's automatic minimum size to zero, so the
   flex algorithm is free to crush it to its 1px border and clip every tab out
   of sight. The bar renders, reads, and links correctly while being invisible,
   which is why it has to be prevented here rather than noticed later. */
.sp-tabs {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: var(--sp-space-1);
    border-bottom: 1px solid var(--sp-border-subtle);
    margin-bottom: var(--sp-space-5);
    overflow-x: auto;
    scrollbar-width: thin;
}

.sp-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-3) var(--sp-space-4);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    top: 1px;
    transition: color var(--sp-duration-fast), border-color var(--sp-duration-fast), background var(--sp-duration-fast);
}

.sp-tab:hover {
    color: var(--sp-text-primary);
    background: color-mix(in oklch, var(--sp-accent) 5%, transparent);
}

.sp-tab--active,
.sp-tab[aria-selected="true"] {
    color: var(--sp-accent);
    border-bottom-color: var(--sp-accent);
}

.sp-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--sp-bg-canvas), 0 0 0 4px color-mix(in oklch, var(--sp-accent) 50%, transparent);
    border-radius: var(--sp-radius-sm);
}

.sp-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 var(--sp-space-1);
    border-radius: var(--sp-radius-full);
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    line-height: 1;
}

.sp-tab--active .sp-tab-count,
.sp-tab[aria-selected="true"] .sp-tab-count {
    background: var(--sp-accent-dim);
    color: var(--sp-accent);
}

.sp-tabs[data-variant="pill"] {
    border-bottom: none;
    gap: var(--sp-space-2);
}

.sp-tabs[data-variant="pill"] .sp-tab {
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-full);
    background: var(--sp-bg-surface);
    top: 0;
}

.sp-tabs[data-variant="pill"] .sp-tab--active,
.sp-tabs[data-variant="pill"] .sp-tab[aria-selected="true"] {
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    border-color: var(--sp-accent);
}

.sp-tabs[data-variant="pill"] .sp-tab--active .sp-tab-count,
.sp-tabs[data-variant="pill"] .sp-tab[aria-selected="true"] .sp-tab-count {
    background: color-mix(in oklch, var(--sp-text-on-accent) 25%, transparent);
    color: var(--sp-text-on-accent);
}

.sp-tab-panel[hidden] {
    display: none;
}

.sp-tab-panel--loading {
    opacity: 0.6;
    pointer-events: none;
}

}

/* Time-range picker — segmented preset pills + custom datetime row.
   Markup: partials/components/time-range.hbs */

@layer components {

.time-range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-3);
    margin-bottom: var(--sp-space-4);
}

.time-range__presets {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: 2px;
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-full);
}

.time-range__btn {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-space-1) var(--sp-space-3);
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    text-decoration: none;
    user-select: none;
    transition: background var(--sp-duration-fast), color var(--sp-duration-fast);
}

.time-range__btn:hover {
    color: var(--sp-text-primary);
    background: color-mix(in oklch, var(--sp-accent) 6%, transparent);
}

.time-range__btn--active {
    background: var(--sp-accent);
    color: var(--sp-text-on-accent, #fff);
    font-weight: 600;
}

.time-range__custom {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: end;
    gap: var(--sp-space-2);
}

.time-range__custom[hidden] {
    display: none;
}

.time-range__label {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.time-range__label-text {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
}

.time-range__input {
    padding: var(--sp-space-1) var(--sp-space-2);
    background: var(--sp-bg-input, var(--sp-bg-surface-raised));
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-sm);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
}

.time-range__input:focus {
    outline: 2px solid color-mix(in oklch, var(--sp-accent) 40%, transparent);
    border-color: var(--sp-accent);
}

.time-range__apply {
    padding: var(--sp-space-1) var(--sp-space-3);
    background: var(--sp-accent);
    border: 1px solid var(--sp-accent);
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-on-accent, #fff);
    cursor: pointer;
    transition: filter var(--sp-duration-fast);
}

.time-range__apply:hover {
    filter: brightness(1.08);
}

}

@layer components {

.rank-bg-1  { background: var(--sp-rank-1-bg); }
.rank-bg-2  { background: var(--sp-rank-2-bg); }
.rank-bg-3  { background: var(--sp-rank-3-bg); }
.rank-bg-4  { background: var(--sp-rank-4-bg); }
.rank-bg-5  { background: var(--sp-rank-5-bg); }
.rank-bg-6  { background: var(--sp-rank-6-bg); }
.rank-bg-7  { background: var(--sp-rank-7-bg); }
.rank-bg-8  { background: var(--sp-rank-8-bg); }
.rank-bg-9  { background: var(--sp-rank-9-bg); }
.rank-bg-10 { background: var(--sp-rank-10-bg); }

.user-widget__level.rank-bg-tier-10 { font-size: 0.5rem; }

.user-widget--tier-1,
.user-widget--tier-2,
.user-widget--tier-3,
.user-widget--tier-4,
.user-widget--tier-5 { }

.user-widget--tier-6 { filter: drop-shadow(0 0 3px color-mix(in oklch, var(--sp-rank-tier-6-color) 25%, transparent)); }
.user-widget--tier-7 { filter: drop-shadow(0 0 3px color-mix(in oklch, var(--sp-rank-tier-7-color) 25%, transparent)); }
.user-widget--tier-8 { filter: drop-shadow(0 0 4px color-mix(in oklch, var(--sp-rank-tier-8-color) 30%, transparent)); }
.user-widget--tier-9 { filter: drop-shadow(0 0 4px color-mix(in oklch, var(--sp-rank-tier-9-color) 30%, transparent)); }
.user-widget--tier-10 { filter: drop-shadow(0 0 6px color-mix(in oklch, var(--sp-rank-tier-10-color) 40%, transparent)); }

.user-widget__level.is-premium {
    border-color: var(--sp-rank-tier-10-color);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--sp-rank-tier-10-color) 40%, transparent),
                0 0 6px color-mix(in oklch, var(--sp-rank-tier-10-color) 30%, transparent);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--sp-radius-full);
    background: linear-gradient(135deg, var(--sp-accent), color-mix(in oklch, var(--sp-accent) 70%, var(--sp-success)));
    color: var(--sp-text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--sp-text-xs);
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    box-shadow: var(--sp-shadow-sm);
    position: relative;
}

.user-name {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
    font-weight: 600;
    line-height: 1.3;
}

.user-meta {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
    background: var(--sp-bg-surface);
    color: var(--sp-text-secondary);
    cursor: pointer;
    transition: color var(--sp-duration-fast),
                background var(--sp-duration-fast),
                border-color var(--sp-duration-fast);
    flex-shrink: 0;
}

.btn-logout:hover {
    color: var(--sp-text-primary);
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-strong);
}

.btn-logout svg {
    display: block;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--sp-radius-full);
    background: linear-gradient(135deg, var(--sp-accent), color-mix(in oklch, var(--sp-accent) 70%, var(--sp-success)));
    color: var(--sp-text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--sp-text-xs);
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.625rem; }

.user-info {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    min-width: 0;
}

.user-level-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: var(--sp-radius-full);
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    font-size: 0.625rem;
    font-weight: 700;
    flex-shrink: 0;
}

.star-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.125rem;
}
.star {
    font-size: var(--sp-text-base);
    line-height: 1;
    cursor: pointer;
    color: var(--sp-text-tertiary);
    transition: color var(--sp-duration-fast);
}
.star-filled { color: var(--sp-warning); }
.star-empty { color: var(--sp-text-tertiary); }
.star-text {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    margin-left: var(--sp-space-1);
}

}

@layer components {

.user-cell {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
}

.user-widget {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    text-decoration: none;
    transition: transform var(--sp-duration-fast);
}

.user-widget:hover {
    transform: scale(1.08);
}

.user-widget__avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--sp-radius-full);
    background: linear-gradient(135deg, var(--sp-accent), color-mix(in oklch, var(--sp-accent) 70%, var(--sp-success)));
    color: var(--sp-text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--sp-text-xs);
    font-weight: 700;
    letter-spacing: 0.02em;
    position: relative;
    z-index: var(--sp-z-sticky);
    overflow: hidden;
}

.user-widget__avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--sp-radius-full);
    display: block;
}

.user-widget__xp-ring {
    position: absolute;
    inset: 0;
    width: 44px;
    height: 44px;
    transform: rotate(-90deg);
    z-index: var(--sp-z-sticky-header);
    pointer-events: none;
}

.user-widget__xp-track {
    fill: none;
    stroke: color-mix(in oklch, var(--sp-text-tertiary) 12%, transparent);
    stroke-width: 2.5;
}

.user-widget__xp-fill {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease-out;
}

.rank-ring-tier-1, .rank-ring-tier-bronze   { stroke: var(--sp-rank-tier-1-color); }
.rank-ring-tier-2, .rank-ring-tier-silver   { stroke: var(--sp-rank-tier-2-color); }
.rank-ring-tier-3, .rank-ring-tier-gold     { stroke: var(--sp-rank-tier-3-color); }
.rank-ring-tier-4, .rank-ring-tier-platinum { stroke: var(--sp-rank-tier-4-color); }
.rank-ring-tier-5, .rank-ring-tier-diamond  { stroke: var(--sp-rank-tier-5-color); }
.rank-ring-tier-6, .rank-ring-tier-emerald  { stroke: var(--sp-rank-tier-6-color); }
.rank-ring-tier-7, .rank-ring-tier-sapphire { stroke: var(--sp-rank-tier-7-color); }
.rank-ring-tier-8, .rank-ring-tier-ruby     { stroke: var(--sp-rank-tier-8-color); }
.rank-ring-tier-9, .rank-ring-tier-obsidian { stroke: var(--sp-rank-tier-9-color); }
.rank-ring-tier-10, .rank-ring-tier-legendary { stroke: var(--sp-rank-tier-10-color); }

.rank-ring-1  { stroke: var(--sp-rank-1-color); }
.rank-ring-2  { stroke: var(--sp-rank-2-color); }
.rank-ring-3  { stroke: var(--sp-rank-3-color); }
.rank-ring-4  { stroke: var(--sp-rank-4-color); }
.rank-ring-5  { stroke: var(--sp-rank-5-color); }
.rank-ring-6  { stroke: var(--sp-rank-6-color); }
.rank-ring-7  { stroke: var(--sp-rank-7-color); }
.rank-ring-8  { stroke: var(--sp-rank-8-color); }
.rank-ring-9  { stroke: var(--sp-rank-9-color); }
.rank-ring-10 { stroke: var(--sp-rank-10-color); }

.user-widget__level {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 22px;
    height: 22px;
    border-radius: var(--sp-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.6rem;
    line-height: 1;
    color: var(--sp-text-on-accent);
    text-shadow: 0 1px 2px oklch(0 0 0 / 0.4);
    border: 2px solid var(--sp-bg-surface);
    z-index: var(--sp-z-sticky-header);
}

.rank-bg-tier-1, .rank-bg-tier-bronze   { background: var(--sp-rank-tier-1-bg); }
.rank-bg-tier-2, .rank-bg-tier-silver   { background: var(--sp-rank-tier-2-bg); }
.rank-bg-tier-3, .rank-bg-tier-gold     { background: var(--sp-rank-tier-3-bg); }
.rank-bg-tier-4, .rank-bg-tier-platinum { background: linear-gradient(135deg, var(--sp-rank-tier-4-bg), var(--sp-rank-tier-4-color)); }
.rank-bg-tier-5, .rank-bg-tier-diamond  { background: linear-gradient(135deg, var(--sp-rank-tier-5-bg), var(--sp-rank-tier-5-color)); }
.rank-bg-tier-6, .rank-bg-tier-emerald  { background: linear-gradient(135deg, var(--sp-rank-tier-6-bg), var(--sp-rank-tier-6-color)); box-shadow: 0 0 4px color-mix(in oklch, var(--sp-rank-tier-6-color) 30%, transparent); }
.rank-bg-tier-7, .rank-bg-tier-sapphire { background: linear-gradient(135deg, var(--sp-rank-tier-7-bg), var(--sp-rank-tier-7-color)); box-shadow: 0 0 4px color-mix(in oklch, var(--sp-rank-tier-7-color) 30%, transparent); }
.rank-bg-tier-8, .rank-bg-tier-ruby     { background: linear-gradient(135deg, var(--sp-rank-tier-8-bg), var(--sp-rank-tier-8-color)); box-shadow: 0 0 6px color-mix(in oklch, var(--sp-rank-tier-8-color) 40%, transparent); }
.rank-bg-tier-9, .rank-bg-tier-obsidian { background: linear-gradient(135deg, var(--sp-rank-tier-9-bg), var(--sp-rank-tier-9-color)); box-shadow: 0 0 6px color-mix(in oklch, var(--sp-rank-tier-9-color) 40%, transparent); }
.rank-bg-tier-10, .rank-bg-tier-legendary { background: linear-gradient(135deg, var(--sp-rank-tier-10-bg), var(--sp-rank-tier-10-color)); box-shadow: 0 0 8px color-mix(in oklch, var(--sp-rank-tier-10-color) 50%, transparent); }

}

@layer components {

/* KPI strip ---------------------------------------------------------------- */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp-space-4);
    margin-block: var(--sp-space-6);
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand);
    padding: var(--sp-space-5);
}

.kpi-card__label {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
}

.kpi-card__value {
    font-size: var(--sp-text-xl);
    font-weight: 600;
    color: var(--sp-text-primary);
    font-variant-numeric: tabular-nums;
}

.kpi-card__sub {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
}

.kpi-card--danger .kpi-card__value { color: var(--sp-danger); }
.kpi-card--warning .kpi-card__value { color: var(--sp-warning); }

/* Chart panels ------------------------------------------------------------- */
.requests-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--sp-space-4);
    margin-block: var(--sp-space-6);
}

/* Panels are flex columns so the chart inside fills the height the grid gives
   the row. Without this a short chart strands itself at the top of a panel
   stretched to match its taller neighbour. */
.requests-charts__panel {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-card-brand);
    padding: var(--sp-space-5);
    min-width: 0;
}

.requests-charts__panel--wide {
    margin-block: var(--sp-space-6);
}

.requests-charts__title {
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-secondary);
    margin: 0 0 var(--sp-space-3);
}

/* Latency histogram — horizontal bars --------------------------------------
   Every cell is pinned to row 1. The label used to rely on sparse
   auto-placement to reach column 1 after a column-3 sibling, which is
   impossible — the cursor never steps backwards — so it wrapped onto an
   implicit second row and lined up with the next bar down. */
.latency-histogram {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
}

.latency-histogram__row {
    display: grid;
    grid-template-columns: 5.5rem 1fr 3rem;
    align-items: center;
    gap: var(--sp-space-3);
    min-height: 1.5rem;
    border-radius: var(--sp-radius-sm);
    transition: background var(--sp-duration-fast);
}

.latency-histogram__row:hover {
    background: color-mix(in oklch, var(--sp-accent) 5%, transparent);
}

.latency-histogram__label {
    grid-column: 1;
    grid-row: 1;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.latency-histogram__track {
    grid-column: 2;
    grid-row: 1;
    height: 0.75rem;
    border-radius: var(--sp-radius-sm);
    background: color-mix(in oklch, var(--sp-warm-900) 6%, transparent);
}

.latency-histogram__fill {
    display: block;
    width: var(--v, 0%);
    height: 100%;
    border-radius: var(--sp-radius-sm);
    background: var(--sp-chart-blue);
}

.latency-histogram__row--peak .latency-histogram__fill {
    background: var(--sp-accent);
}

.latency-histogram__count {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    font-size: var(--sp-text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--sp-text-tertiary);
}

.latency-histogram__axis {
    display: flex;
    justify-content: space-between;
    margin-top: var(--sp-space-2);
    padding-top: var(--sp-space-1);
    padding-left: calc(5.5rem + var(--sp-space-3));
    border-top: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

/* Time series — vertical bars with a labelled axis --------------------------
   Bars grow from a baseline via their own height, not a background gradient in
   a fixed-height box, so the plot fills whatever height the panel gives it
   instead of stranding itself at the top. */
.timeseries {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
    flex: 1;
    margin: 0;
    min-width: 0;
}

.timeseries__head {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.timeseries__title {
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.timeseries__subtitle {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.timeseries__plot {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-space-3);
    flex: 1;
    min-height: 150px;
}

/* Axis labels sit at the top, middle, and baseline of the plot, which is what
   ties a bar's height back to a number the reader can name. */
.timeseries__y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.timeseries__bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    border-bottom: 1px solid var(--sp-border-default);
    background-image: linear-gradient(
        to bottom,
        var(--sp-border-subtle) 1px,
        transparent 1px 100%
    );
    background-size: 100% 50%;
    background-repeat: repeat-y;
}

.timeseries__bar {
    flex: 1 1 0;
    min-width: 0;
    height: var(--v, 0%);
    border-radius: var(--sp-radius-sm) var(--sp-radius-sm) 0 0;
    background: var(--sp-chart-blue);
    transition: filter var(--sp-duration-fast);
}

.timeseries[data-tone="success"] .timeseries__bar {
    background: var(--sp-chart-green);
}

.timeseries__bar:hover {
    filter: brightness(1.12);
}

.timeseries__x-axis {
    display: flex;
    justify-content: space-between;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.chart-caption {
    margin: 0;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 150px;
    margin: 0;
    border: 1px dashed var(--sp-border-subtle);
    border-radius: var(--sp-radius-sm);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
}


/* Trace waterfall ---------------------------------------------------------- */
.waterfall {
    margin: var(--sp-space-6) 0 0;
}

.waterfall__legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.waterfall__legend li {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
}

.waterfall__swatch {
    display: inline-block;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: var(--sp-radius-sm);
    background: var(--sp-warm-500);
}

.waterfall__swatch--gateway    { background: var(--sp-chart-blue); }
.waterfall__swatch--governance { background: var(--sp-chart-amber); }
.waterfall__swatch--tool       { background: var(--sp-chart-green); }
.waterfall__swatch--model      { background: var(--sp-chart-purple); }
.waterfall__swatch--spawn      { background: var(--sp-chart-indigo); }

.waterfall__root {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    margin-top: var(--sp-space-4);
}

.waterfall__row {
    display: grid;
    grid-template-columns: minmax(8rem, 14rem) 1fr auto;
    align-items: center;
    gap: var(--sp-space-3);
    min-height: 1.5rem;
}

.waterfall__name {
    font-size: var(--sp-text-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waterfall__track {
    position: relative;
    height: 0.75rem;
    background: color-mix(in oklch, var(--sp-warm-900) 5%, transparent);
    border-radius: var(--sp-radius-sm);
}

.waterfall__bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--start, 0%);
    width: var(--w, 0.5%);
    min-width: 2px;
    border-radius: var(--sp-radius-sm);
    background: var(--sp-warm-500);
}

.waterfall__bar--gateway    { background: var(--sp-chart-blue); }
.waterfall__bar--governance { background: var(--sp-chart-amber); }
.waterfall__bar--tool       { background: var(--sp-chart-green); }
.waterfall__bar--model      { background: var(--sp-chart-purple); }
.waterfall__bar--spawn      { background: var(--sp-chart-indigo); }

.waterfall__dur {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

}

@layer components {

.panel-overlay {
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0);
    z-index: calc(var(--sp-z-panel) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--sp-duration-slow) var(--sp-ease-in-out),
                visibility var(--sp-duration-slow) var(--sp-ease-in-out),
                background var(--sp-duration-slow) var(--sp-ease-in-out),
                backdrop-filter var(--sp-duration-slow) var(--sp-ease-in-out);
    backdrop-filter: blur(0px);
}

.panel-overlay.open,
.panel-overlay.active {
    opacity: 1;
    visibility: visible;
    background: var(--sp-overlay-light);
    backdrop-filter: blur(4px);
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 640px;
    max-width: 94vw;
    height: 100vh;
    background: var(--sp-bg-surface-gradient);
    border-left: 1px solid var(--sp-border-subtle);
    box-shadow: var(--sp-shadow-float);
    z-index: var(--sp-z-panel);
    transform: translateX(100%);
    transition: transform var(--sp-duration-slow) var(--sp-ease-out);
    display: flex;
    flex-direction: column;
    border-radius: var(--sp-radius-card) 0 0 var(--sp-radius-card-brand);
}

.side-panel.open { transform: translateX(0); }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-space-6) var(--sp-space-8);
    border-bottom: 1px solid var(--sp-border-default);
    background: var(--sp-bg-card-header);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: var(--sp-text-lg);
    font-weight: 600;
    margin: 0;
    color: var(--sp-text-primary);
    letter-spacing: -0.01em;
}

.panel-close {
    background: color-mix(in oklch, var(--sp-warm-900) 6%, transparent);
    border: none;
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-lg);
    cursor: pointer;
    padding: var(--sp-space-1) var(--sp-space-2);
    border-radius: var(--sp-radius-sm);
    line-height: 1;
    transition: color var(--sp-duration-fast),
                background var(--sp-duration-fast);
}

.panel-close:hover {
    color: var(--sp-text-primary);
    background: color-mix(in oklch, var(--sp-warm-900) 8%, transparent);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-space-8);
}

.panel-footer {
    padding: var(--sp-space-4) var(--sp-space-8);
    border-top: 1px solid var(--sp-border-subtle);
    display: flex;
    gap: var(--sp-space-3);
    justify-content: flex-end;
    flex-shrink: 0;
}

@keyframes panelContentIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.side-panel.open .panel-body .form-group,
.side-panel.open .panel-body .detail-section {
    animation: panelContentIn var(--sp-duration-slow) var(--sp-ease-in-out) both;
}

.side-panel.open .panel-body .form-group:nth-child(1),
.side-panel.open .panel-body .detail-section:nth-child(1) { animation-delay: 50ms; }
.side-panel.open .panel-body .form-group:nth-child(2),
.side-panel.open .panel-body .detail-section:nth-child(2) { animation-delay: 100ms; }
.side-panel.open .panel-body .form-group:nth-child(3),
.side-panel.open .panel-body .detail-section:nth-child(3) { animation-delay: 150ms; }
.side-panel.open .panel-body .form-group:nth-child(4),
.side-panel.open .panel-body .detail-section:nth-child(4) { animation-delay: 200ms; }
.side-panel.open .panel-body .form-group:nth-child(n+5),
.side-panel.open .panel-body .detail-section:nth-child(n+5) { animation-delay: 250ms; }

@media (prefers-reduced-motion: reduce) {
    .panel-overlay {
        transition: none;
    }
    .side-panel {
        transition: none;
    }
    .side-panel.open .panel-body .form-group,
    .side-panel.open .panel-body .detail-section {
        animation: none;
    }
}

}

@layer components {

.detail-section {
    margin-bottom: var(--sp-space-6);
    padding-bottom: var(--sp-space-5);
    border-bottom: 1px solid var(--sp-border-subtle);
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-section h3 {
    font-size: var(--sp-text-lg);
    font-weight: 600;
    margin: 0 0 var(--sp-space-4);
    color: var(--sp-text-primary);
    letter-spacing: -0.01em;
}

.detail-section h4 {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
    margin: 0 0 var(--sp-space-3);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-space-4);
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
}

.detail-label {
    font-size: var(--sp-text-xs);
    font-weight: 500;
    color: var(--sp-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-value {
    font-size: var(--sp-text-base);
    color: var(--sp-text-primary);
}

.panel-loading {
    text-align: center;
    padding: var(--sp-space-12);
    color: var(--sp-text-tertiary);
}
.sp-skill-detail-field {
    margin-bottom: var(--sp-space-2);
}

.sp-skill-detail-label {
    font-weight: 600;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    margin-right: var(--sp-space-2);
}

.sp-skill-detail-value {
    font-size: var(--sp-text-sm);
}

.sp-skill-prompt-section {
    margin-top: var(--sp-space-3);
}

.sp-skill-prompt-label {
    font-weight: 600;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    margin-bottom: var(--sp-space-1);
}

.sp-skill-prompt-pre {
    font-size: var(--sp-text-xs);
    max-height: 200px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--sp-bg-surface-raised);
    padding: var(--sp-space-3);
    border-radius: var(--sp-radius-sm);
}

@media (max-width: 768px) {
    .side-panel {
        width: 100vw;
        max-width: 100vw;
    }

    .edit-panel,
    .assign-panel {
        width: 100vw;
    }

    .panel-header {
        padding: var(--sp-space-3) var(--sp-space-4);
    }

    .panel-body {
        padding: var(--sp-space-3) var(--sp-space-4);
    }

    .panel-footer {
        padding: var(--sp-space-3) var(--sp-space-4);
    }

    .form-row,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-wrap: wrap;
    }

    .form-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
    }

    .checklist-item {
        min-height: 2.75rem;
        padding: var(--sp-space-1) 0;
    }

    .checklist-item input[type="checkbox"] {
        width: 1.375rem;
        height: 1.375rem;
    }
}

}

@layer components {

.form-group {
    margin-bottom: var(--sp-space-5);
    border-radius: var(--sp-radius-card-inner);
}

.form-group label {
    display: block;
    font-size: var(--sp-text-sm);
    font-weight: 500;
    color: var(--sp-text-secondary);
    margin-bottom: var(--sp-space-1);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--sp-bg-base);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-inner);
    padding: var(--sp-space-2) var(--sp-space-3);
    color: var(--sp-text-primary);
    font-size: var(--sp-text-base);
    font-family: inherit;
    outline: none;
    transition: border-color var(--sp-duration-fast), box-shadow var(--sp-duration-fast);
    box-sizing: border-box;
}

.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
    border-color: var(--sp-accent);
    outline: 2px solid var(--sp-accent-dim);
    outline-offset: -1px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--sp-text-disabled);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group .error-msg {
    font-size: var(--sp-text-sm);
    color: var(--sp-danger);
    margin-top: var(--sp-space-1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-space-4);
}

.checklist-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-space-5);
}

.form-section {
    margin-top: var(--sp-space-6);
    padding-top: var(--sp-space-5);
    border-top: 1px solid var(--sp-border-subtle);
}

.form-section-heading {
    font-size: var(--sp-text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
    margin: 0 0 var(--sp-space-4);
}

@media (min-width: 769px) {
    .checklist-grid {
        grid-template-columns: 1fr 1fr;
    }
    .checklist-grid > :only-child,
    .checklist-grid > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

.form-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    margin-top: var(--sp-space-6);
    padding-top: var(--sp-space-5);
    border-top: 1px solid var(--sp-border-subtle);
}

.btn[aria-busy="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn[aria-busy="true"]::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.125em;
    height: 1.125em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--sp-radius-full);
    animation: spin 0.6s linear infinite;
    color: var(--sp-text-on-accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    min-height: 2.75rem;
}

.checklist-item label {
    flex: 1;
    cursor: pointer;
    padding: var(--sp-space-2) 0;
}

.checklist-item input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}

.form-hint {
    font-weight: 400;
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-xs);
}

.error-msg:empty {
    display: none;
}

}

@layer components {


    .plugin-detail-row > td {
        padding: 0;
        background: var(--sp-bg-surface-raised);
        border-bottom: 1px solid var(--sp-border-subtle);
    }

    .plugin-detail-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--sp-space-4);
        padding: var(--sp-space-4) var(--sp-space-5);
    }

    .plugin-detail-section h5 {
        margin: 0 0 var(--sp-space-2);
        font-size: var(--sp-text-xs);
        font-weight: 600;
        color: var(--sp-text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .plugin-detail-section .config-resource-table td {
        padding: var(--sp-space-1) var(--sp-space-2);
        font-size: var(--sp-text-xs);
    }

    .plugin-detail-section .toggle-switch {
        transform: scale(0.75);
    }

    .plugin-detail-section .empty-inline {
        font-size: var(--sp-text-xs);
        color: var(--sp-text-tertiary);
        margin: 0;
    }

    .plugin-detail-section.active {
        background: var(--sp-bg-surface);
        border-radius: var(--sp-radius-sm);
        padding: var(--sp-space-2);
    }

    .btn-icon-remove {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        border: none;
        background: none;
        color: var(--sp-text-tertiary);
        font-size: var(--sp-text-sm);
        cursor: pointer;
        border-radius: var(--sp-radius-xs);
        transition: color var(--sp-duration-fast), background var(--sp-duration-fast);
        vertical-align: middle;
        margin-left: var(--sp-space-1);
    }
    .btn-icon-remove:hover {
        color: var(--sp-danger);
        background: var(--sp-danger-dim);
    }

    .add-row td {
        border-top: 1px dashed var(--sp-border-subtle);
        padding-top: var(--sp-space-2);
    }

    .add-checklist {
        max-height: 300px;
        overflow-y: auto;
        margin: var(--sp-space-3) 0;
    }
    .add-checklist label {
        display: flex;
        align-items: center;
        gap: var(--sp-space-2);
        padding: var(--sp-space-1) var(--sp-space-2);
        font-size: var(--sp-text-sm);
        cursor: pointer;
        border-radius: var(--sp-radius-xs);
    }
    .add-checklist label:hover {
        background: var(--sp-bg-surface-raised);
    }
    .add-checklist-empty {
        color: var(--sp-text-tertiary);
        font-size: var(--sp-text-sm);
        padding: var(--sp-space-3);
        text-align: center;
    }

    .assign-panel-empty {
        color: var(--sp-text-tertiary);
        font-size: var(--sp-text-sm);
    }

    .marketplace-card-expand-trigger {
        cursor: pointer;
        color: var(--sp-accent);
        font-size: var(--sp-text-xs);
        font-weight: 500;
    }
    .marketplace-card-expand-trigger:hover { text-decoration: underline; }

    .plugin-users-container { margin-top: var(--sp-space-4); }

    .plugins-list {
        display: flex;
        flex-direction: column;
        gap: var(--sp-space-3);
    }

    @media (max-width: 768px) {
        .plugin-detail-content {
            grid-template-columns: 1fr;
        }
    }

}

@layer components {
.settings-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-space-5);
}
.settings-field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
}
.settings-label {
    font-weight: 600;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
}
.settings-hint { font-size: var(--sp-text-xs); color: var(--sp-text-tertiary); }
.settings-avatar-row { display: flex; gap: var(--sp-space-3); align-items: center; }
.settings-avatar-row .form-input { flex: 1; }
.settings-avatar-preview {
    width: 40px;
    height: 40px;
    border-radius: var(--sp-radius-full);
    overflow: hidden;
    background: var(--sp-bg-surface-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--sp-border-default);
}
.settings-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.settings-avatar-placeholder {
    font-size: var(--sp-text-lg);
    color: var(--sp-text-tertiary);
    font-weight: 600;
}
.settings-divider {
    height: 1px;
    background: var(--sp-border-subtle);
    margin: var(--sp-space-6) 0;
}
.settings-section-title {
    font-size: var(--sp-text-base);
    font-weight: 600;
    margin-bottom: var(--sp-space-4);
    color: var(--sp-text-primary);
}
.settings-toggles { display: flex; flex-direction: column; gap: var(--sp-space-4); }
.settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-space-3);
    cursor: pointer;
    padding: var(--sp-space-3) var(--sp-space-4);
    border-radius: var(--sp-radius-card-brand);
    border: 1px solid var(--sp-border-subtle);
    transition: background var(--sp-duration-fast) var(--sp-ease-out);
}
.settings-toggle:hover {
    background: var(--sp-accent-dim);
}
.settings-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.settings-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: color-mix(in oklch, var(--sp-text-tertiary) 25%, transparent);
    border-radius: var(--sp-radius-lg);
    transition: background var(--sp-duration-fast) var(--sp-ease-out);
    flex-shrink: 0;
    margin-top: 0.125rem;
}
.settings-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--sp-toggle-knob);
    border-radius: var(--sp-radius-full);
    transition: transform var(--sp-duration-fast) var(--sp-ease-out);
    box-shadow: var(--sp-shadow-xs);
}
.settings-toggle input:checked + .settings-toggle-slider { background: var(--sp-accent); }
.settings-toggle input:checked + .settings-toggle-slider::after { transform: translateX(20px); }
.settings-toggle input:focus-visible + .settings-toggle-slider {
    outline: 2px solid var(--sp-accent);
    outline-offset: 2px;
}
.settings-toggle-text { display: flex; flex-direction: column; gap: 0.125rem; }
.settings-toggle-text strong { font-size: var(--sp-text-sm); color: var(--sp-text-primary); }
.settings-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    margin-top: var(--sp-space-6);
}
.settings-save-status {
    font-size: var(--sp-text-sm);
    transition: opacity var(--sp-duration-fast) var(--sp-ease-out);
}
.settings-save-status--success { color: var(--sp-success); }
.settings-save-status--error { color: var(--sp-danger); }.save-secret-btn,
.toggle-hook-btn {
    padding: var(--sp-space-1) var(--sp-space-3);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    background: transparent;
    color: var(--sp-text-secondary);
    cursor: pointer;
    transition: all var(--sp-duration-fast);
}
.save-secret-btn:hover,
.toggle-hook-btn:hover {
    background: var(--sp-accent-dim);
    border-color: var(--sp-accent);
    color: var(--sp-accent);
}
.card--danger {
    border: 1px solid color-mix(in oklch, var(--sp-danger) 30%, transparent);
}
.card--danger .card-title {
    color: var(--sp-danger);
}
.danger-zone-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-4);
}
.danger-zone-item p {
    margin-top: var(--sp-space-1);
}
.settings-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-4);
}

.text-error { color: var(--sp-danger); }

.cert-fp {
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
    word-break: break-all;
    color: var(--sp-text-secondary);
}

.form-input--readonly {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-tertiary);
    border-style: dashed;
    cursor: not-allowed;
}

.settings-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    margin-top: var(--sp-space-5);
    padding: var(--sp-space-3) 0;
    background: var(--sp-bg-surface);
    border-top: 1px solid var(--sp-border-subtle);
}

@media (max-width: 768px) {
    .settings-form-grid { grid-template-columns: 1fr; }
    .danger-zone-item { flex-direction: column; align-items: flex-start; }
}
}

@layer components {

.admin-footer {
    padding: var(--sp-space-4) var(--sp-space-10);
    border-top: 1px solid var(--sp-sidebar-border);
    text-align: center;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    flex-shrink: 0;
}

.admin-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-space-2);
    flex-wrap: wrap;
}

.admin-footer-brand {
    font-weight: 600;
    color: var(--sp-text-secondary);
}

.admin-footer-sep {
    opacity: 0.4;
}

.admin-footer-link {
    color: var(--sp-text-tertiary);
    text-decoration: none;
    transition: color var(--sp-duration-fast);
}

.admin-footer-link:hover {
    color: var(--sp-accent);
}

.admin-footer-link:focus-visible {
    outline: 2px solid var(--sp-accent);
    outline-offset: 2px;
    border-radius: var(--sp-radius-sm);
}

@media (max-width: 480px) {
    .admin-footer {
        padding: var(--sp-space-3) var(--sp-space-4);
        padding-bottom: calc(var(--sp-space-3) + env(safe-area-inset-bottom, 0px));
    }
}

}

@layer components {

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--sp-space-5);
    background:
        radial-gradient(ellipse at 30% 20%, color-mix(in oklch, var(--sp-accent) 6%, transparent) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, color-mix(in oklch, oklch(0.62 0.18 260) 4%, transparent) 0%, transparent 50%),
        linear-gradient(180deg, var(--sp-bg-canvas) 0%, var(--sp-bg-base) 100%);
}

.login-container .card {
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 8px 32px oklch(0.20 0.02 50 / 0.10), 0 2px 8px oklch(0.20 0.02 50 / 0.06);
    border-radius: var(--sp-radius-card-brand);
    background: oklch(1.0 0 0);
    border: 1px solid oklch(0.20 0.01 50 / 0.06);
    padding: var(--sp-space-8) var(--sp-space-6);
}

.login-title {
    font-size: var(--sp-text-xl);
    font-weight: 700;
    margin: 0 0 var(--sp-space-1);
    color: var(--sp-text-primary);
}

.login-subtitle {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
    margin: 0 0 var(--sp-space-5);
}

.login-error {
    display: none;
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
    padding: var(--sp-space-2) var(--sp-space-4);
    border-radius: var(--sp-radius-md);
    font-size: var(--sp-text-sm);
    margin-bottom: var(--sp-space-4);
    text-align: left;
}

.login-error.visible {
    display: block;
}

.login-loading {
    flex-direction: column;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-5);
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-sm);
}

.login-loading:not([hidden]) {
    display: flex;
}

.login-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--sp-border-default);
    border-top-color: var(--sp-accent);
    border-radius: var(--sp-radius-full);
    animation: spin var(--sp-duration-slow) linear infinite;
}

.login-retry {
    display: none;
    margin-top: var(--sp-space-2);
}

.login-retry.visible {
    display: block;
}

.login-retry a {
    color: var(--sp-accent);
    text-decoration: none;
    font-size: var(--sp-text-sm);
}

.login-retry a:hover {
    text-decoration: underline;
}

.login-logo img {
    max-width: 100%;
    height: auto;
}

.login-logo .logo-dark { display: none; }

@media (prefers-color-scheme: dark) {
    .login-logo .logo-light { display: none; }
    .login-logo .logo-dark { display: block; }
}


.login-container .form-group input:focus-visible,
.login-container .form-group select:focus-visible,
.login-container .form-group textarea:focus-visible {
    outline: 2px solid var(--sp-accent);
    outline-offset: 2px;
}


.login-container .btn,
.login-container button[type="submit"] {
    border-radius: var(--sp-radius-button);
}


@media (prefers-color-scheme: dark) {
    .login-container .card {
        background: var(--sp-bg-glass);
        backdrop-filter: blur(16px);
        border: 1px solid var(--sp-bg-glass-border);
    }
}

main.login-container {
    display: flex;
}

/* ── Split auth layout (login / register) ─────────────────────
   Two columns: an explanatory info panel + the sign-in card. */
.auth-page {
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 30% 20%, color-mix(in oklch, var(--sp-accent) 6%, transparent) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, color-mix(in oklch, var(--sp-section-plugins) 4%, transparent) 0%, transparent 50%),
        linear-gradient(180deg, var(--sp-bg-canvas) 0%, var(--sp-bg-base) 100%);
}

.auth-info {
    flex: 1;
    max-width: 640px;
    padding: 3rem 3rem 3rem 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-width: 420px;
}

.auth-info h2 {
    font-size: var(--sp-text-md);
    font-weight: 700;
    color: var(--sp-text-primary);
    margin: 1.5rem 0 0.5rem;
}
.auth-info h3 {
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
    margin: 0.75rem 0 0.25rem;
}
.auth-info p {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    line-height: 1.6;
    margin: 0 0 0.5rem;
}
.auth-info .text-muted { color: var(--sp-text-tertiary); }

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--sp-accent-dim);
    color: var(--sp-accent-hover);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: var(--sp-radius-full);
    margin-bottom: 1rem;
}

.auth-divider {
    border: none;
    border-top: 1px solid var(--sp-border-default);
    margin: 1.25rem 0;
}

.auth-flow-steps {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.auth-flow-step {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    line-height: 1.5;
}

.auth-flow-step .step-num,
.auth-page .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    border-radius: var(--sp-radius-full);
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    font-size: var(--sp-text-xs);
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

@media (max-width: 900px) {
    .auth-page { flex-direction: column; }
    .auth-info { max-width: 100%; padding: 2rem 1.5rem 1rem; }
    .auth-form-col { min-width: 0; padding: 1rem 1.5rem 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .login-spinner {
        animation: none;
    }
}


.auth-more > summary {
    cursor: pointer;
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-secondary);
    padding: var(--sp-space-2) 0;
    user-select: none;
}

.auth-more > summary:hover {
    color: var(--sp-accent);
}

}

@layer components {

@media (max-width: 768px) {

    .user-widget {
        width: 38px;
        height: 38px;
    }

    .user-widget__avatar {
        width: 30px;
        height: 30px;
        font-size: 0.6rem;
    }

    .user-widget__xp-ring {
        width: 38px;
        height: 38px;
    }

    .user-widget__level {
        width: 18px;
        height: 18px;
        font-size: 0.55rem;
    }

    .user-meta {
        display: none;
    }

    .toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--sp-space-2);
        align-items: center;
    }

    .toolbar .search-group {
        flex: 1 1 140px;
        min-width: 140px;
    }

    .toolbar .search-input,
    .search-input {
        min-width: 0;
        width: 100%;
    }

    .toolbar .filter-select,
    .toolbar .filter-group {
        flex: 0 1 auto;
        min-width: 100px;
    }

    .toolbar .btn-primary {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: var(--sp-space-2) var(--sp-space-3);
        font-size: var(--sp-text-sm);
    }

    .toolbar .flex-1 {
        display: none;
    }

    .btn {
        min-height: 44px;
        font-weight: 500;
    }

    .admin-main > p.text-muted.mb-4 {
        display: none;
    }

    .config-stats.mb-4 {
        margin-bottom: var(--sp-space-2);
    }

    .btn-sm {
        min-height: 36px;
    }

    .actions-trigger,
    .btn-actions-trigger {
        min-width: 44px;
        min-height: 44px;
    }

    .install-trigger {
        min-width: 44px;
        min-height: 44px;
    }

    .install-dropdown {
        width: calc(100vw - var(--sp-space-6));
        right: calc(-1 * var(--sp-space-3));
    }
}

@media (max-width: 480px) {

    .toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--sp-space-2);
    }

    .toolbar .search-group {
        flex: 1 1 0;
        min-width: 120px;
    }

    .toolbar .btn-primary {
        flex: 0 0 auto;
        width: auto;
        min-width: auto;
    }

    .toolbar .filter-select,
    .toolbar .filter-group {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .user-widget {
        width: 34px;
        height: 34px;
    }

    .user-widget__avatar {
        width: 26px;
        height: 26px;
        font-size: 0.55rem;
    }

    .user-widget__xp-ring {
        width: 34px;
        height: 34px;
    }

    .user-widget__level {
        width: 16px;
        height: 16px;
        font-size: 0.5rem;
    }

    .install-dropdown {
        width: calc(100vw - var(--sp-space-4));
        right: calc(-1 * var(--sp-space-2));
    }

    .install-dropdown .install-widget-stats {
        flex-wrap: wrap;
        gap: var(--sp-space-2) var(--sp-space-3);
    }
}

}

/* Governance Policies — chain layout and enforcement panel.
   Used by storage/files/admin/templates/governance.hbs. Bundled into
   admin-bundle.css by jobs/bundle_admin_css. */

.policy-chain-intro {
    margin: var(--sp-space-6) 0 var(--sp-space-4);
    padding: var(--sp-space-5) var(--sp-space-6);
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-brand, var(--sp-radius-card));
}

.policy-chain-intro__title {
    margin: 0 0 var(--sp-space-2);
    font-size: var(--sp-text-lg);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.policy-chain-intro__body {
    margin: 0 0 var(--sp-space-2);
    color: var(--sp-text-secondary);
    line-height: 1.55;
}

.policy-chain-intro__hint {
    margin: 0;
    font-size: var(--sp-text-sm);
    line-height: 1.5;
}

/* Chain ---------------------------------------------------------------- */

.policy-chain {
    list-style: none;
    margin: 0 0 var(--sp-space-8);
    padding: 0;
    display: grid;
    gap: 0;
}

.policy-chain__step {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    gap: var(--sp-space-4);
    padding-bottom: var(--sp-space-4);
}

.policy-chain__step--disabled .policy-chain__card {
    opacity: 0.65;
}

.policy-chain__rail {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.policy-chain__order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--sp-radius-full);
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-default);
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-text-primary);
    z-index: 1;
}

.policy-chain__step--disabled .policy-chain__order {
    color: var(--sp-text-muted);
    background: var(--sp-bg-surface);
}

.policy-chain__connector {
    flex: 1;
    width: 2px;
    margin-top: var(--sp-space-1);
    background: linear-gradient(
        to bottom,
        var(--sp-border-default),
        var(--sp-border-default) 60%,
        transparent
    );
}

.policy-chain__card {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-brand, var(--sp-radius-card));
    padding: var(--sp-space-5);
    display: grid;
    gap: var(--sp-space-4);
}

.policy-chain__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-space-3);
    flex-wrap: wrap;
}

.policy-chain__title {
    display: flex;
    align-items: baseline;
    gap: var(--sp-space-3);
    flex-wrap: wrap;
    min-width: 0;
}

.policy-chain__name {
    font-size: var(--sp-text-lg);
    font-weight: 600;
    color: var(--sp-text-primary);
    text-decoration: none;
}

.policy-chain__name:hover {
    color: var(--sp-accent);
    text-decoration: underline;
}

.policy-chain__id {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-muted);
}

.policy-chain__description {
    margin: 0;
    color: var(--sp-text-secondary);
    line-height: 1.55;
}

/* Meta (as-code + config) --------------------------------------------- */

.policy-chain__meta {
    margin: 0;
    display: grid;
    gap: var(--sp-space-2);
    padding: var(--sp-space-3) var(--sp-space-4);
    background: var(--sp-bg-surface-alt, var(--sp-bg-surface-raised));
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-inner-brand, var(--sp-radius-card-inner));
}

.policy-chain__meta-row {
    display: grid;
    grid-template-columns: 6rem 1fr;
    gap: var(--sp-space-3);
    align-items: baseline;
}

.policy-chain__meta-row dt {
    margin: 0;
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-muted);
    font-weight: 600;
}

.policy-chain__meta-row dd {
    margin: 0;
    min-width: 0;
    word-break: break-word;
}

.policy-chain__params {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--sp-space-1);
}

.policy-chain__params li {
    font-size: var(--sp-text-sm);
}

.policy-chain__param-value {
    color: var(--sp-text-primary);
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-sm);
}

/* Stats strip ---------------------------------------------------------- */

.policy-chain__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--sp-space-3);
}

.policy-chain__stat {
    display: grid;
    gap: var(--sp-space-1);
    padding: var(--sp-space-3) var(--sp-space-4);
    background: var(--sp-bg-surface-alt, var(--sp-bg-surface-raised));
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
    text-decoration: none;
    color: inherit;
}

a.policy-chain__stat:hover {
    border-color: var(--sp-border-strong);
    background: var(--sp-bg-surface-raised);
}

.policy-chain__stat-value {
    font-size: var(--sp-text-xl);
    font-weight: 600;
    color: var(--sp-text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.policy-chain__stat-label {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-muted);
}

.policy-chain__stat--allow .policy-chain__stat-value {
    color: var(--sp-success);
}

.policy-chain__stat--deny:not(.policy-chain__stat--zero) .policy-chain__stat-value {
    color: var(--sp-danger);
}

.policy-chain__actions {
    display: flex;
    gap: var(--sp-space-2);
    flex-wrap: wrap;
}

/* Enforcement section ------------------------------------------------- */

.enforcement-section {
    margin-top: var(--sp-space-8);
    display: grid;
    gap: var(--sp-space-5);
}

.enforcement-section__header h2 {
    margin: 0 0 var(--sp-space-1);
    font-size: var(--sp-text-xl);
    font-weight: 600;
}

.enforcement-section__header p {
    margin: 0;
}

.enforcement-section__sub {
    margin: var(--sp-space-2) 0 var(--sp-space-3);
    font-size: var(--sp-text-base);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.enforcement-section__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
    gap: var(--sp-space-6);
    align-items: start;
}

/* Number-aligned cells in enforcement tables */
.enforcement-section .data-table td.num,
.enforcement-section .data-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.enforcement-section .data-table tr.row-muted td {
    opacity: 0.7;
}

/* Orphan / historical drawer ------------------------------------------ */

.policy-chain-orphans {
    margin-top: var(--sp-space-8);
    padding: var(--sp-space-3) var(--sp-space-4);
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-md);
}

.policy-chain-orphans > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--sp-text-secondary);
}

.policy-chain-orphans[open] > summary {
    margin-bottom: var(--sp-space-3);
}

@media (max-width: 720px) {
    .policy-chain__meta-row {
        grid-template-columns: 1fr;
    }
    .policy-chain__step {
        grid-template-columns: 2rem 1fr;
        gap: var(--sp-space-3);
    }
}

@layer responsive {

@media (max-width: 768px) {
    .dashboard-two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .admin-main > *:not(.admin-footer) {
        padding-left: var(--sp-space-2);
        padding-right: var(--sp-space-2);
    }
    .admin-footer {
        padding-left: var(--sp-space-2);
        padding-right: var(--sp-space-2);
        padding-bottom: calc(var(--sp-space-3) + env(safe-area-inset-bottom, 0px));
    }

    .admin-header {
        padding: var(--sp-space-2);
    }

    .admin-header h1 {
        font-size: var(--sp-text-base);
    }

    .admin-sidebar {
        width: 100vw;
    }

    .card, .stat-card, .health-card {
        --sp-shadow-card: var(--sp-shadow-sm);
        --sp-shadow-card-hover: var(--sp-shadow-md);
    }
    .plugin-card {
        --sp-shadow-card: var(--sp-shadow-sm);
        --sp-shadow-card-hover: var(--sp-shadow-md);
    }    .dashboard-two-col {
        grid-template-columns: 1fr;
    }
}

@media (hover: none) {
    .data-table tr:hover td {
        background: inherit;
    }
    .btn-actions-trigger:hover,
    .actions-trigger:hover {
        background: transparent;
        border-color: var(--sp-border-default);
        color: var(--sp-text-secondary);
    }
    .admin-sidebar nav a:hover {
        background: transparent;
        color: var(--sp-text-secondary);
    }
    .stat-card:hover {
        transform: none;
        box-shadow: none;
    }
}

@media print {
    .admin-layout .admin-sidebar,
    .admin-layout .sidebar-toggle,
    .admin-layout .sidebar-overlay,
    .admin-layout .toolbar .btn-primary,
    .admin-layout .pagination,
    .admin-layout .actions-popup,
    .admin-layout .col-actions {
        display: none;
    }

    .admin-layout .admin-main {
        padding: 0;
    }

    .admin-layout .table-container {
        border: none;
        margin: 0;
    }
}

}

@layer responsive {
@media (max-width: 768px) {
    .header-actions {
        position: relative;
        flex-shrink: 0;
    }
    .header-actions-toggle {
        display: flex;
    }
    .header-actions-menu {
        display: none;
        position: absolute;
        top: calc(100% + var(--sp-space-2));
        right: 0;
        background: var(--sp-bg-surface);
        border: 1px solid var(--sp-border-default);
        border-radius: var(--sp-radius-md);
        box-shadow: var(--sp-shadow-lg);
        padding: var(--sp-space-2);
        min-width: 200px;
        z-index: var(--sp-z-sticky-header);
        flex-direction: column;
        gap: var(--sp-space-2);
    }
    .header-actions.open .header-actions-menu {
        display: flex;
    }
    .header-actions-menu .header-help-link {
        width: 100%;
        height: auto;
        border-radius: var(--sp-radius-sm);
        padding: var(--sp-space-2) var(--sp-space-3);
        justify-content: flex-start;
        gap: var(--sp-space-2);
    }
    .header-actions-menu .header-help-link::after {
        content: 'Help';
        font-size: var(--sp-text-sm);
        color: var(--sp-text-secondary);
    }
    .header-actions-menu .install-menu {
        width: 100%;
    }
    .header-actions-menu .install-trigger {
        width: 100%;
        justify-content: flex-start;
        padding: var(--sp-space-2) var(--sp-space-3);
        gap: var(--sp-space-2);
        border-radius: var(--sp-radius-sm);
        min-height: 40px;
    }
    .header-actions-menu .install-trigger::after {
        content: 'Share & Install';
        font-size: var(--sp-text-sm);
        color: var(--sp-text-secondary);
    }
    .header-actions-menu .user-widget-row {
        display: flex;
        align-items: center;
        gap: var(--sp-space-2);
        padding: var(--sp-space-2) var(--sp-space-3);
    }
    .header-actions-menu .user-widget {
        width: 38px;
        height: 38px;
    }
    .header-actions-menu .user-widget__xp-ring {
        width: 38px;
        height: 38px;
    }
    .header-actions-menu .install-dropdown {
        position: fixed;
        top: auto;
        right: var(--sp-space-3);
        left: var(--sp-space-3);
        width: auto;
    }

    .section-title {
        font-size: var(--sp-text-sm);
        margin: var(--sp-space-4) 0 var(--sp-space-2);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .toast-container {
        left: var(--sp-space-3);
        right: var(--sp-space-3);
        top: var(--sp-space-3);
    }
    .toast {
        max-width: none;
    }
}
}

@layer responsive {
html, body {
    overflow-x: hidden;
}
@media (max-width: 1024px) {
    .admin-main {
        --sp-gutter: var(--sp-space-5);
    }
}

@media (max-width: 768px) {
    .admin-layout {
        display: block;
        height: auto;
        overflow-y: auto;
    }

    .sidebar-toggle {
        display: flex;
    }
    .sidebar-close-btn {
        display: flex;
    }
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: var(--sp-z-sidebar-drawer);
        transform: translateX(-100%);
        transition: transform var(--sp-duration-slow) var(--sp-ease-out);
        box-shadow: none;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--sp-shadow-xl);
    }
    .admin-sidebar nav a {
        padding: var(--sp-space-3) var(--sp-space-5);
        min-height: 44px;
    }

    .admin-main {
        overflow-x: hidden;
        max-width: 100vw;
        --sp-gutter: var(--sp-space-3);
    }
    /* Full-bleed containers span exactly the viewport and scroll internally;
       any wider and the body itself pans sideways. */
    .admin-main .table-container,
    .admin-main .table-scroll,
    .admin-main .toolbar {
        max-width: 100vw;
    }
    .admin-main .toolbar {
        flex-wrap: wrap;
    }
    .admin-footer {
        padding-left: var(--sp-space-3);
        padding-right: var(--sp-space-3);
        padding-bottom: calc(var(--sp-space-4) + env(safe-area-inset-bottom, 0px));
    }

    .admin-header {
        position: sticky;
        top: 0;
        z-index: var(--sp-z-sticky-header);
        background: var(--sp-bg-canvas);
        gap: var(--sp-space-2);
        margin-top: 0;
        padding: var(--sp-space-2) var(--sp-space-3);
        margin-bottom: var(--sp-space-3);
        border-bottom: 1px solid var(--sp-border-subtle);
        box-shadow: var(--sp-shadow-sm);
        flex-wrap: nowrap;
    }
    .admin-header h1 {
        font-size: var(--sp-text-lg);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .admin-sidebar {
        transition: none;
    }
}
}

@layer utilities {

.marketplace-empty-heading {
  font-size: var(--sp-text-lg);
  font-weight: 600;
  margin: 0 0 var(--sp-space-2);
}
.marketplace-empty-text {
  max-width: 420px;
  margin: 0 auto var(--sp-space-5);
  line-height: 1.5;
}

.plugin-view-header {
  margin: 0 0 var(--sp-space-2);
  font-size: var(--sp-text-xl);
  font-weight: 700;
}
.plugin-view-desc {
  margin: 0 0 var(--sp-space-3);
  max-width: 600px;
}

.panel-title-inline {
  margin: 0;
  font-size: var(--sp-text-lg);
}

.link-primary-bold {
  color: var(--sp-text-primary);
  text-decoration: underline;
  font-weight: 500;
}

.badge-padded { padding: var(--sp-space-1) var(--sp-space-3); }
.btn-compact { font-size: var(--sp-text-xs); padding: 0.125rem var(--sp-space-2); }

.mkt-list { display: flex; flex-direction: column; gap: var(--sp-space-3); }
.mkt-card-accent { border-left: 3px solid var(--sp-accent); }
.mkt-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--sp-radius-full);
  background: var(--sp-accent);
  color: var(--sp-text-on-accent);
  font-weight: 700;
  font-size: var(--sp-text-xs);
}
.mkt-card-title { margin: 0; font-size: var(--sp-text-base); font-weight: 600; color: var(--sp-text-primary); }
.mkt-card-desc { margin: var(--sp-space-1) 0 0; font-size: var(--sp-text-sm); color: var(--sp-text-secondary); }
.mkt-expand-icon {
  font-size: var(--sp-text-sm);
  color: var(--sp-text-tertiary);
  transition: transform var(--sp-duration-fast) var(--sp-ease-out);
  display: inline-block;
}
.mkt-details {
  padding: var(--sp-space-3);
  border-top: 1px solid var(--sp-border-primary);
}
.min-w-0 { min-width: 0; }.mb-1 { margin-bottom: var(--sp-space-1); }

}

@layer utilities {

.review-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--sp-space-3);
}

.bar-track {
  flex: 1;
  background: var(--sp-bg-surface-raised);
  border-radius: var(--sp-radius-xs);
  height: 20px;
  overflow: hidden;
}
.bar-fill {
  background: var(--sp-accent);
  width: var(--sp-fill);
  height: 100%;
  border-radius: var(--sp-radius-xs);
  transition: width 0.3s;
}

.hook-code-row { display: none; }
.form-row { display: flex; gap: var(--sp-space-3); }
.form-row > * { flex: 1; }

.empty-centered {
  text-align: center;
  padding: var(--sp-space-12) var(--sp-space-6);
  color: var(--sp-text-secondary);
}.text-accent { color: var(--sp-accent); }
.text-no-decor { text-decoration: none; }.nowrap { white-space: nowrap; }
.flex-col { flex-direction: column; }
.overflow-hidden { overflow: hidden; }

.min-w-sm { min-width: 40px; }
.min-w-filter { min-width: 140px; }
.progress-track-sm {
  background: var(--sp-bg-tertiary);
  border-radius: var(--sp-radius-sm);
  height: 8px;
  overflow: hidden;
}
.progress-fill-primary {
  background: var(--sp-accent);
  height: 100%;
  border-radius: var(--sp-radius-sm);
}

.fork-indicator {
  margin-bottom: var(--sp-space-3);
  padding: var(--sp-space-2) var(--sp-space-3);
  background: var(--sp-bg-warning);
  border-radius: var(--sp-radius-md);
  font-size: var(--sp-text-sm);
}

.achievement-name { font-weight: 600; font-size: var(--sp-text-sm); color: var(--sp-text-primary); }
.achievement-detail { font-size: var(--sp-text-xs); color: var(--sp-text-tertiary); margin-top: var(--sp-space-1); }

.detail-pre-wrap {
  white-space: pre-wrap;
  font-size: var(--sp-text-sm);
  color: var(--sp-text-secondary);
  max-height: 200px;
  overflow: auto;
  margin-top: var(--sp-space-2);
}
.user-level-badge--sm {
  width: 24px;
  height: 24px;
  font-size: 0.6rem;
}

.login-error--success {
  color: var(--sp-success);
  border-color: var(--sp-success);
}

.card-footer {
  padding: var(--sp-space-4) var(--sp-space-6);
  border-top: 1px solid var(--sp-border-subtle);
  display: flex;
  align-items: center;
  gap: var(--sp-space-3);
}

.font-normal { font-weight: 400; }
.theme-label {
  font-size: var(--sp-text-sm);
  color: var(--sp-text-secondary);
  font-weight: 500;
}
}

@layer utilities {.d-grid { display: grid; }.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }.gap-4 { gap: var(--sp-space-4); }.gap-6 { gap: var(--sp-space-6); }.mb-1 { margin-bottom: var(--sp-space-1); }
.mb-2 { margin-bottom: var(--sp-space-2); }
.mb-3 { margin-bottom: var(--sp-space-3); }
.mb-4 { margin-bottom: var(--sp-space-4); }.mb-6 { margin-bottom: var(--sp-space-6); }.mt-2 { margin-top: var(--sp-space-2); }
.mt-3 { margin-top: var(--sp-space-3); }
.mt-4 { margin-top: var(--sp-space-4); }.p-4 { padding: var(--sp-space-4); }
.p-5 { padding: var(--sp-space-5); }.text-xs { font-size: var(--sp-text-xs); }
.text-sm { font-size: var(--sp-text-sm); }
.text-base { font-size: var(--sp-text-base); }
.text-lg { font-size: var(--sp-text-lg); }
.text-xl { font-size: var(--sp-text-xl); }
.text-2xl { font-size: var(--sp-text-2xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--sp-text-primary); }
.text-secondary { color: var(--sp-text-secondary); }
.text-tertiary { color: var(--sp-text-tertiary); }
.text-danger { color: var(--sp-danger); }
.text-success { color: var(--sp-success); }
.text-underline { text-decoration: underline; }

.w-full { width: 100%; }.max-w-md { max-width: 560px; }
.max-w-lg { max-width: 800px; }
.max-w-xl { max-width: 1080px; }
.box-border { box-sizing: border-box; }

.min-w-label { min-width: 180px; }
.min-w-count { min-width: 60px; }

.wizard-heading {
  margin: 0 0 var(--sp-space-4);
  font-size: var(--sp-text-lg);
  font-weight: 600;
}
.wizard-card {
  max-width: 800px;
  padding: var(--sp-space-5);
}
.wizard-heading-xl {
  margin: var(--sp-space-4) 0 var(--sp-space-5);
  font-size: var(--sp-text-xl);
  font-weight: 600;
}

.checklist-scroll {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--sp-border-subtle);
  border-radius: var(--sp-radius-md);
  padding: var(--sp-space-2);
}
.checklist-filter-row {
  display: flex;
  gap: var(--sp-space-2);
  margin-bottom: var(--sp-space-2);
}
.checklist-empty { padding: var(--sp-space-4); }

.confirm-actions {
  display: flex;
  gap: var(--sp-space-3);
  justify-content: flex-end;
  margin-top: var(--sp-space-5);
}

}

/* User detail + users-table runtime visualisations */

.agent-pill,
.token-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
  background: var(--color-surface-2, rgba(0, 0, 0, 0.03));
  color: var(--color-text, inherit);
}

.agent-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: currentColor;
  opacity: 0.55;
  box-shadow: 0 0 0 0 currentColor;
}

.agent-pill--live { color: var(--color-success, #15803d); border-color: rgba(21, 128, 61, 0.3); }
.agent-pill--live .agent-dot { opacity: 1; animation: agent-pulse 1.6s ease-out infinite; }
.agent-pill--idle { color: var(--color-muted, #6b7280); }

.token-pill--fresh { color: var(--color-success, #15803d); border-color: rgba(21, 128, 61, 0.3); }
.token-pill--fresh .agent-dot { opacity: 1; animation: agent-pulse 1.6s ease-out infinite; }
.token-pill--idle  { color: #b45309; border-color: rgba(180, 83, 9, 0.3); }
.token-pill--stale { color: var(--color-muted, #6b7280); }
.token-pill--never { color: var(--color-muted, #9ca3af); }

@keyframes agent-pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 6px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

/* Inline edit form on user-detail page */
.user-edit-form .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  align-self: end;
}

.form-field--readonly {
  color: var(--color-muted, #6b7280);
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-muted, #4b5563);
}

.user-edit-form input[type="text"],
.user-edit-form input[type="email"],
.user-edit-form select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
  border-radius: 6px;
  background: var(--color-surface, #fff);
  color: inherit;
  font: inherit;
}

.user-edit-form input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.form-status {
  font-size: 0.875rem;
  color: var(--color-muted, #6b7280);
}

.runtime-meta {
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.toolbar--compact {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.card-header h3 { margin: 0; }

/* Recent-activity feed (user-detail "Recent Activity" card) */
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-space-3);
  padding: var(--sp-space-3) 0;
  border-bottom: 1px solid var(--sp-border-subtle);
}
.feed-item:last-child { border-bottom: none; }

.feed-icon {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.4rem;
  border-radius: var(--sp-radius-full);
  background: var(--sp-text-tertiary);
}
.feed-icon.feed-blue   { background: var(--sp-section-plugins); }
.feed-icon.feed-orange { background: var(--sp-section-export); }
.feed-icon.feed-green  { background: var(--sp-section-skills); }
.feed-icon.feed-purple { background: var(--sp-section-users); }
.feed-icon.feed-cyan   { background: var(--sp-chart-indigo); }

.feed-content {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-space-1) var(--sp-space-3);
  min-width: 0;
}

.feed-text {
  font-size: var(--sp-text-sm);
  color: var(--sp-text-primary);
  min-width: 0;
}

.feed-time {
  font-size: var(--sp-text-xs);
  color: var(--sp-text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Unified Access Control page (/admin/access-control).
 *
 * Three-pane layout:
 *   .ac-toolbar                — top status + actions
 *   .ac-layout                 — grid: tree (left) + detail (center)
 *     .ac-tree                 — departments tree
 *     .ac-detail               — context-sensitive center pane
 */

.ac-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-3);
    align-items: center;
    margin: var(--sp-space-3) 0 var(--sp-space-2);
}
.ac-toolbar .ac-search-group {
    flex: 1 1 240px;
}
.ac-toolbar .search-input {
    width: 100%;
}
.ac-source-pill {
    flex: 1 1 320px;
    padding: var(--sp-space-2) var(--sp-space-3);
    border-radius: 8px;
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    cursor: help;
}
.ac-source-pill strong {
    color: var(--sp-text-primary);
}
.ac-stats {
    display: flex;
    gap: var(--sp-space-2);
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    margin-bottom: var(--sp-space-3);
}
.ac-stats strong {
    color: var(--sp-text-primary);
}

.ac-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: var(--sp-space-4);
    align-items: start;
}
@media (max-width: 900px) {
    .ac-layout {
        grid-template-columns: 1fr;
    }
}

.ac-tree {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 12px;
    padding: var(--sp-space-3);
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    position: sticky;
    top: var(--sp-space-3);
    color: var(--sp-text-primary);
}
.ac-tree-heading {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
    margin: 0 0 var(--sp-space-2);
}
.ac-tree-dept {
    margin-bottom: var(--sp-space-2);
}
.ac-dept-row {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-space-2) var(--sp-space-3);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    color: var(--sp-text-primary);
}
.ac-dept-row:hover,
.ac-dept-row[aria-pressed="true"] {
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-subtle);
}
.ac-dept-count {
    font-size: var(--sp-text-xs);
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--sp-text-secondary);
    font-weight: 500;
}
.ac-dept-users {
    list-style: none;
    margin: 4px 0 0;
    padding: 0 0 0 var(--sp-space-2);
    border-left: 2px solid var(--sp-border-subtle);
}
.ac-dept-users li {
    margin: 2px 0;
}
.ac-user-row {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 5px var(--sp-space-2);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
}
.ac-user-row.is-inactive {
    opacity: 0.55;
}
.ac-user-row:hover,
.ac-user-row[aria-pressed="true"] {
    background: var(--sp-bg-surface-raised);
    border-color: var(--sp-border-subtle);
}
.ac-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 6px;
    flex: 1;
}
.ac-user-roles {
    display: flex;
    gap: 4px;
}
.ac-role-chip {
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-xs);
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 500;
}

.ac-detail {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 12px;
    padding: var(--sp-space-4);
    min-height: 400px;
    color: var(--sp-text-primary);
}
.ac-welcome h2 {
    margin-top: 0;
    color: var(--sp-text-primary);
}
.ac-welcome p {
    color: var(--sp-text-secondary);
}
.ac-welcome-tips {
    margin-top: var(--sp-space-3);
    padding-left: 1.2em;
    color: var(--sp-text-secondary);
}
.ac-welcome-tips li {
    margin-bottom: var(--sp-space-2);
}
.ac-welcome-tips code,
.ac-modal-hint code,
.ac-detail code {
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--sp-text-primary);
}

/* Department editor */
.ac-dept-editor h2 {
    margin: 0 0 var(--sp-space-2);
    color: var(--sp-text-primary);
}
.ac-dept-editor .ac-section {
    margin-top: var(--sp-space-3);
}
.ac-dept-editor .ac-section h3 {
    margin: 0 0 var(--sp-space-2);
    font-size: var(--sp-text-md);
    color: var(--sp-text-primary);
}
.ac-dept-rule-list {
    border: 1px solid var(--sp-border-subtle);
    border-radius: 8px;
    overflow: hidden;
    background: var(--sp-bg-surface);
}
.ac-dept-rule {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px 120px;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-2) var(--sp-space-3);
    border-bottom: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
}
.ac-dept-rule:last-child { border-bottom: none; }
.ac-dept-rule select {
    padding: 4px 8px;
    font-size: var(--sp-text-sm);
    border: 1px solid var(--sp-border-default);
    border-radius: 6px;
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
}

/* User matrix */
.ac-user-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    margin-bottom: var(--sp-space-3);
}
.ac-user-header h2 { margin: 0; color: var(--sp-text-primary); }
.ac-user-meta {
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    flex-wrap: wrap;
}
.ac-user-meta select {
    padding: 4px 8px;
    font-size: var(--sp-text-sm);
    border: 1px solid var(--sp-border-default);
    border-radius: 6px;
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
}
.ac-matrix-section {
    margin-top: var(--sp-space-3);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 8px;
    overflow: hidden;
    background: var(--sp-bg-surface);
}
.ac-matrix-section-header {
    background: var(--sp-bg-surface-raised);
    padding: var(--sp-space-2) var(--sp-space-3);
    font-weight: 600;
    font-size: var(--sp-text-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--sp-text-primary);
    border-bottom: 1px solid var(--sp-border-subtle);
}
.ac-matrix-row {
    display: grid;
    grid-template-columns: 1fr 90px 220px 160px;
    align-items: center;
    gap: var(--sp-space-3);
    padding: var(--sp-space-2) var(--sp-space-3);
    border-top: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
}
.ac-matrix-row:first-child { border-top: none; }
.ac-matrix-entity {
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-matrix-entity .id {
    font-family: var(--sp-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    display: block;
}
.ac-effective {
    text-align: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    border: 1px solid transparent;
}
.ac-effective.is-allow {
    background: var(--sp-success-dim);
    color: var(--sp-success);
    border-color: color-mix(in oklch, var(--sp-success) 35%, transparent);
}
.ac-effective.is-deny  {
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
    border-color: color-mix(in oklch, var(--sp-danger) 35%, transparent);
}
.ac-source {
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-xs);
}
.ac-source .ac-layer-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    margin-right: 4px;
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    color: var(--sp-text-secondary);
}
.ac-source .ac-layer-tag.is-user {
    background: var(--sp-warning-dim);
    color: var(--sp-warning);
    border-color: color-mix(in oklch, var(--sp-warning) 30%, transparent);
}
.ac-source .ac-layer-tag.is-department {
    background: color-mix(in oklch, var(--sp-color-info) 14%, transparent);
    color: var(--sp-color-info);
    border-color: color-mix(in oklch, var(--sp-color-info) 30%, transparent);
}
.ac-source .ac-layer-tag.is-role {
    background: color-mix(in oklch, var(--sp-accent) 14%, transparent);
    color: var(--sp-accent);
    border-color: color-mix(in oklch, var(--sp-accent) 30%, transparent);
}
.ac-source .ac-layer-tag.is-default {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-tertiary);
    border-color: var(--sp-border-subtle);
}
.ac-override {
    display: flex;
    gap: 4px;
}
.ac-override button {
    padding: 4px 8px;
    border: 1px solid var(--sp-border-default);
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
    border-radius: 6px;
    font-size: var(--sp-text-xs);
    cursor: pointer;
}
.ac-override button:hover {
    background: var(--sp-bg-surface-raised);
}
.ac-override button[aria-pressed="true"] {
    background: var(--sp-bg-surface-raised);
}
.ac-override button.is-allow[aria-pressed="true"] {
    background: var(--sp-success-dim);
    color: var(--sp-success);
    border-color: color-mix(in oklch, var(--sp-success) 45%, transparent);
}
.ac-override button.is-deny[aria-pressed="true"]  {
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
    border-color: color-mix(in oklch, var(--sp-danger) 45%, transparent);
}

/* Modals */
.panel-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 80;
}
.ac-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 12px;
    width: min(640px, 90vw);
    max-height: 85vh;
    overflow: auto;
    z-index: 90;
    box-shadow: var(--sp-shadow-lg);
}
.ac-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-space-3) var(--sp-space-4);
    border-bottom: 1px solid var(--sp-border-subtle);
}
.ac-modal-header h2 {
    margin: 0;
    font-size: var(--sp-text-lg);
    color: var(--sp-text-primary);
}
.ac-modal-body {
    padding: var(--sp-space-4);
}
.ac-modal-hint {
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
    margin: 0 0 var(--sp-space-3);
}
.ac-yaml-pre {
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 8px;
    padding: var(--sp-space-3);
    font-size: var(--sp-text-sm);
    max-height: 50vh;
    overflow: auto;
    white-space: pre-wrap;
    color: var(--sp-text-primary);
}
.ac-modal-actions {
    display: flex;
    gap: var(--sp-space-2);
    justify-content: flex-end;
    margin-top: var(--sp-space-3);
}
.ac-field {
    display: block;
    margin-bottom: var(--sp-space-3);
}
.ac-field span {
    display: block;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    margin-bottom: 4px;
}
.ac-field input.search-input,
.ac-field input[type="text"] {
    width: 100%;
    padding: 6px 10px;
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
    border: 1px solid var(--sp-border-default);
    border-radius: 6px;
}
.ac-form-error {
    color: var(--sp-danger);
    font-size: var(--sp-text-sm);
    margin: 0 0 var(--sp-space-2);
    min-height: 1em;
}
.panel-close {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--sp-text-tertiary);
}
.panel-close:hover {
    color: var(--sp-text-primary);
}

.ac-dept-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.ac-user-matrix {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
    min-width: 0;
}

.ac-welcome-title {
    margin: 0 0 var(--sp-space-2);
    font-size: var(--sp-text-lg);
    font-weight: 600;
    color: var(--sp-text-primary);
}

.ac-welcome-tips-wrap > summary {
    cursor: pointer;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    user-select: none;
    margin-top: var(--sp-space-3);
}

/* /admin/entities/contexts — list + detail page styles.

   The KPI card itself is defined once, in 09-charts.css. This file used to
   carry a second, unlayered copy: being unlayered it outranked every @layer
   components rule, so the contexts pages quietly rendered a different card to
   the rest of the admin surface. */

@layer components {

.contexts-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--sp-space-3);
    margin-bottom: var(--sp-space-5);
}

@media (max-width: 1100px) {
    .contexts-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .contexts-kpis { grid-template-columns: repeat(2, 1fr); }
}

.toolbar__field {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

.toolbar__field-label {
    font-weight: 500;
    color: var(--sp-text-tertiary);
}

.toolbar__field .select {
    appearance: auto;
    padding: var(--sp-space-2) var(--sp-space-3);
    border: 1px solid var(--sp-border-default);
    border-radius: var(--sp-radius-button);
    background: var(--sp-bg-surface);
    color: var(--sp-text-primary);
    font-size: var(--sp-text-sm);
    font-family: inherit;
    min-width: 140px;
    cursor: pointer;
}

.toolbar__field .select:hover {
    border-color: var(--sp-accent);
}

.toolbar__field .select:focus-visible {
    outline: none;
    border-color: var(--sp-accent);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--sp-accent) 25%, transparent);
}

.time-range-pills {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: 2px;
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-full);
}

.time-range-pills .pill {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-space-1) var(--sp-space-3);
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    cursor: pointer;
    transition: background var(--sp-duration-fast), color var(--sp-duration-fast);
    user-select: none;
}

.time-range-pills .pill input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.time-range-pills .pill:hover {
    color: var(--sp-text-primary);
    background: color-mix(in oklch, var(--sp-accent) 6%, transparent);
}

.time-range-pills .pill--active {
    background: var(--sp-accent);
    color: #fff;
    font-weight: 600;
}

.contexts-kpis + .toolbar,
[data-page="contexts"] {
    margin-bottom: var(--sp-space-4);
}

[data-page="contexts"] .row-expansion[hidden] { display: none; }

[data-page="contexts"] .row-expansion > td {
    background: var(--sp-bg-surface-raised);
    padding: 0;
}

[data-page="contexts"] .data-table--nested {
    width: 100%;
    margin: 0;
    background: transparent;
    border: none;
}

[data-page="contexts"] .data-table--nested th {
    background: transparent;
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--sp-space-2) var(--sp-space-4);
    border-bottom: 1px solid var(--sp-border-subtle);
}

[data-page="contexts"] .data-table--nested td {
    padding: var(--sp-space-2) var(--sp-space-4);
    border-bottom: 1px dashed var(--sp-border-subtle);
}

[data-page="contexts"] .row-expand-toggle {
    transition: transform var(--sp-duration-fast);
}

.link-strong {
    color: var(--sp-text-primary);
    font-weight: 600;
    text-decoration: none;
}

.link-strong:hover {
    color: var(--sp-accent);
    text-decoration: underline;
}

.text-xs { font-size: var(--sp-text-xs); }

/* ---------- conversation preview column ---------- */

/* The opening user turn, so the table says what each conversation was about
   without opening it. Capped and ellipsised so it cannot push the numeric
   columns off screen; the full text is in the cell's title attribute. */
.col-conversation {
    max-width: 28rem;
    min-width: 12rem;
}

.conversation-preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
}

@media (max-width: 1200px) {
    .col-conversation { max-width: 18rem; }
}

}

/* /admin/entities/contexts/{id} — conversation detail page.
   Targets: back link, summary chips, and the transcript message stream.

   The transcript is the point of this page, so it is styled as a real
   conversation surface: a bordered panel ground with role-differentiated
   message blocks, rather than body text separated by hairlines. Rules live in
   @layer components so they sit above the shared table/card defaults. */

@layer components {

/* ---------- back link + summary chips ---------- */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    font-size: var(--sp-text-sm);
    font-weight: 500;
    color: var(--sp-text-tertiary);
    margin-bottom: var(--sp-space-3);
    transition: color var(--sp-duration-fast);
}
.back-link:hover {
    color: var(--sp-accent);
}

.trace-detail__summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2) var(--sp-space-4);
    padding: var(--sp-space-3) var(--sp-space-4);
    margin: var(--sp-space-4) 0 var(--sp-space-5);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-corners-md);
    box-shadow: var(--sp-shadow-card);
}

.trace-detail__field {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
    min-width: 0;
}

.trace-detail__label {
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
    white-space: nowrap;
}

.trace-detail__field a {
    color: var(--sp-text-primary);
    text-decoration: none;
}
.trace-detail__field a:hover {
    color: var(--sp-accent);
    text-decoration: underline;
}

/* ---------- conversation panel ---------- */

.overview-pane {
    margin: 0 0 var(--sp-space-6);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-corners-md);
    box-shadow: var(--sp-shadow-card);
    overflow: hidden;
}

/* Panel header: sits on the raised tone so the message stream below reads as
   the recessed content area. */
.overview-pane > .section-title {
    margin: 0;
    padding: var(--sp-space-3) var(--sp-space-5);
    background: var(--sp-bg-surface-alt);
    border-bottom: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
}

.overview-pane > .transcript,
.overview-pane > .empty-state {
    padding: var(--sp-space-5);
}

/* The requests table shares the panel, but runs full-bleed to its edges so its
   own row borders line up with the panel border. */
.overview-pane > .data-table {
    margin: 0;
    width: 100%;
}

/* The panel is already the card, so the table container inside it drops its own
   border, radius, and shadow rather than drawing a second card one pixel in.
   It keeps .table-scroll, which is the point: a wide table scrolls sideways
   inside the panel instead of widening the page. */
.overview-pane > .table-container {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* ---------- transcript: message stream ---------- */

/* One column, one left edge. This is an audit surface: turns are read in
   sequence and compared against each other, which indented or side-aligned
   message bubbles actively obstruct. */
.transcript {
    list-style: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
}

.transcript__entry {
    display: block;
    padding: 0;
    border: none;
}

/* Message block. A role-coloured rail carries the speaker; every turn keeps the
   same left edge and the same full width. */
.transcript__entry--user,
.transcript__entry--assistant {
    padding: var(--sp-space-3) var(--sp-space-4);
    border: 1px solid var(--sp-border-subtle);
    border-inline-start: 3px solid var(--sp-border-default);
    border-radius: var(--sp-radius-card-inner);
}

.transcript__entry--user {
    background: var(--sp-accent-surface);
    border-color: color-mix(in oklch, var(--sp-accent) 24%, transparent);
    border-inline-start-color: var(--sp-accent);
}

.transcript__entry--assistant {
    background: var(--sp-bg-surface-alt);
    border-inline-start-color: var(--sp-section-users);
}

/* ---------- message meta line ---------- */

.transcript__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-space-2) var(--sp-space-3);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Telemetry rail: what this turn cost and how it was served. Pushed to the end
   of the meta line so the role and time stay flush left and the numbers form a
   readable column down the thread. */
.transcript__meta {
    margin-inline-start: auto;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.transcript__meta-item {
    white-space: nowrap;
}

.transcript__meta-model {
    font-family: var(--sp-font-mono);
    color: var(--sp-text-secondary);
}

.transcript__meta-sep {
    color: var(--sp-border-default);
}

.transcript__meta-status--error {
    color: var(--sp-danger);
    font-weight: 600;
}

.transcript__role {
    font-size: var(--sp-text-sm);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--sp-text-secondary);
}

.transcript__entry--user .transcript__role      { color: var(--sp-accent); }
.transcript__entry--assistant .transcript__role { color: var(--sp-section-users); }
.transcript__entry--tool .transcript__role      { color: var(--sp-warning); }

.transcript__time {
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* Sits after the telemetry rail, which owns the auto margin, and is given a
   real affordance — it was indistinguishable from the surrounding text. */
.transcript__req {
    color: var(--sp-text-tertiary);
    border: 1px solid var(--sp-border-subtle);
    text-decoration: none;
    transition: color var(--sp-duration-fast), border-color var(--sp-duration-fast);
}

.transcript__req:hover {
    color: var(--sp-accent);
    border-color: var(--sp-accent);
}

.transcript__body {
    margin: var(--sp-space-2) 0 0;
    font-size: var(--sp-text-base);
    line-height: 1.65;
    color: var(--sp-text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- transcript: tool entries ---------- */

/* Tool calls are machine turns, not speech: full width, monospaced accent, and
   collapsed by default so they never bury the conversation. */
.transcript__tool {
    margin: 0;
    background: var(--sp-bg-surface-raised);
    border: 1px solid var(--sp-border-subtle);
    border-inline-start: 3px solid var(--sp-warning);
    border-radius: var(--sp-radius-card-inner);
    overflow: hidden;
}

.transcript__tool-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-space-2);
    cursor: pointer;
    list-style: none;
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    padding: var(--sp-space-2) var(--sp-space-3);
    transition: background var(--sp-duration-fast);
}

.transcript__tool-summary:hover {
    background: var(--sp-bg-surface-overlay);
}

.transcript__tool-summary::-webkit-details-marker { display: none; }

.transcript__tool-chevron {
    display: inline-block;
    transition: transform var(--sp-duration-fast);
    color: var(--sp-warning);
    font-size: var(--sp-text-sm);
    line-height: 1;
}

.transcript__tool[open] .transcript__tool-chevron {
    transform: rotate(90deg);
}

.transcript__tool[open] .transcript__tool-summary {
    border-bottom: 1px solid var(--sp-border-subtle);
}

.transcript__tool-name {
    color: var(--sp-text-primary);
    font-family: var(--sp-font-mono);
    font-weight: 600;
}

.transcript__tool-detail {
    padding: var(--sp-space-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
}

.transcript__tool-detail .code-block {
    max-height: 20rem;
}

.transcript__tool-detail details > summary {
    cursor: pointer;
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sp-text-tertiary);
    font-weight: 600;
    margin-bottom: var(--sp-space-2);
}

/* ---------- transcript: system divider ---------- */

/* A system turn is a boundary marker, not a message: it opts out of the
   message-block treatment entirely and renders as a labelled rule. */
.transcript__entry--system {
    padding: 0;
    background: none;
    border: none;
}

.transcript__system {
    display: flex;
    align-items: center;
    gap: var(--sp-space-3);
    padding: var(--sp-space-1) 0;
    background: none;
    border: none;
    margin-inline: 0;
}

.transcript__system-rule {
    flex: 1;
    height: 0;
    border: none;
    border-top: 1px dashed var(--sp-border-default);
    margin: 0;
}

.transcript__system-label {
    display: inline-flex;
    align-items: baseline;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
    flex-shrink: 0;
}

/* The .transcript--compact variant is gone: its only caller was this page's
   transcript, and all it did was undo the line-height the messages are legible
   at. Density is not worth an unreadable conversation. */

/* ---------- responsive ---------- */

@media (max-width: 700px) {
    .overview-pane > .transcript,
    .overview-pane > .empty-state {
        padding: var(--sp-space-3);
    }
    .overview-pane > .section-title {
        padding: var(--sp-space-2) var(--sp-space-3);
    }
    /* The telemetry rail stops being a rail: at this width it wraps under the
       role and time rather than being pushed to a right edge that is no longer
       far enough away to read as a column. */
    .transcript__meta {
        margin-inline-start: 0;
        flex-basis: 100%;
    }
    .trace-detail__summary {
        gap: var(--sp-space-2);
        padding: var(--sp-space-2) var(--sp-space-3);
    }
}

/* ---------- print ---------- */

@media print {
    .overview-pane { box-shadow: none; }
    .transcript__entry { break-inside: avoid; }
    .transcript__tool[open] .code-block { max-height: none; overflow: visible; }
}

}

/* ═══════════════════════════════════════════════════════════
   Profile pane — bridge feature parity
   ═══════════════════════════════════════════════════════════ */

.sp-profile {
    --sp-profile-radius: var(--sp-radius-card-brand, 14px);
    --sp-profile-radius-sm: var(--sp-radius-md, 8px);
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-4);
    color: var(--sp-text-primary);
    padding-bottom: var(--sp-space-8);
    min-width: 0;
}

/* ── HERO ─────────────────────────────────────────────────── */
.sp-profile-hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--sp-space-5);
    align-items: center;
    padding: var(--sp-space-5) var(--sp-space-6);
    background:
        linear-gradient(135deg,
            color-mix(in oklch, var(--sp-accent) 6%, var(--sp-bg-surface)),
            var(--sp-bg-surface) 60%);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-profile-radius);
    box-shadow: var(--sp-shadow-card, none);
    position: relative;
    overflow: hidden;
}

.sp-profile-hero::after {
    content: "";
    position: absolute;
    inset: 0 0 auto auto;
    width: 280px;
    height: 280px;
    background: radial-gradient(
        circle at top right,
        color-mix(in oklch, var(--sp-accent) 18%, transparent),
        transparent 70%
    );
    pointer-events: none;
    z-index: 0;
}

.sp-profile-hero > * { position: relative; z-index: 1; }

.sp-profile-hero__avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sp-accent), color-mix(in oklch, var(--sp-accent) 60%, var(--sp-text-primary)));
    color: oklch(0.99 0 0);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    box-shadow: 0 4px 12px color-mix(in oklch, var(--sp-accent) 25%, transparent);
}

.sp-profile-hero__main {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-2);
    min-width: 0;
}

.sp-profile-hero__name {
    font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--sp-text-primary);
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-profile-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    align-items: center;
}

.sp-profile-hero__email {
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
}

.sp-profile-hero__sub {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-4);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    margin-top: var(--sp-space-1);
}

.sp-kv {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    min-width: 0;
}
.sp-kv__k {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--sp-text-tertiary);
}
.sp-kv__v {
    color: var(--sp-text-secondary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent;
    padding: 0;
}

.sp-profile-hero__quickstats {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: var(--sp-space-5);
    align-items: center;
}

.sp-quickstat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.sp-quickstat__value {
    font-size: clamp(1rem, 0.85rem + 0.5vw, 1.25rem);
    font-weight: 700;
    color: var(--sp-text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.sp-quickstat__label {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
    font-weight: 600;
}

@media (max-width: 900px) {
    .sp-profile-hero {
        grid-template-columns: auto 1fr;
    }
    .sp-profile-hero__quickstats {
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--sp-space-3);
    }
    .sp-quickstat { align-items: flex-start; }
}

/* ── ROW LAYOUT ───────────────────────────────────────────── */
.sp-profile-row {
    display: grid;
    gap: var(--sp-space-4);
    min-width: 0;
}
.sp-profile-row--2 {
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 900px) {
    .sp-profile-row--2 { grid-template-columns: 1fr; }
}

/* ── CARD ─────────────────────────────────────────────────── */
.sp-profile-card {
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-profile-radius);
    box-shadow: var(--sp-shadow-card, 0 1px 2px rgba(0,0,0,0.04));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.sp-profile-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-3);
    padding: var(--sp-space-4) var(--sp-space-5);
    border-bottom: 1px solid var(--sp-border-subtle);
    background: var(--sp-bg-surface-alt);
    flex-wrap: wrap;
    min-width: 0;
}

.sp-profile-card__title {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    min-width: 0;
}

.sp-profile-card__title h2 {
    font-size: var(--sp-text-base);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--sp-text-primary);
}

.sp-icon {
    width: 18px;
    height: 18px;
    color: var(--sp-accent);
    flex-shrink: 0;
}

.sp-profile-card__hint {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.sp-profile-card__stats {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    font-variant-numeric: tabular-nums;
}
.sp-profile-card__stats b { color: var(--sp-text-primary); font-weight: 700; }
.sp-stat-sep { color: var(--sp-text-tertiary); }

/* card body — anything that's not __head */
.sp-profile-card > *:not(.sp-profile-card__head) {
    padding: var(--sp-space-4) var(--sp-space-5);
}
.sp-profile-card > *:not(.sp-profile-card__head):not(:last-child) {
    padding-bottom: 0;
}

/* ── CHIPS ────────────────────────────────────────────────── */
.sp-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: var(--sp-text-xs);
    font-weight: 600;
    background: var(--sp-bg-surface-alt);
    color: var(--sp-text-secondary);
    border: 1px solid var(--sp-border-subtle);
    text-transform: lowercase;
    line-height: 1.6;
    white-space: nowrap;
}
.sp-chip--accent {
    background: color-mix(in oklch, var(--sp-accent) 14%, var(--sp-bg-surface));
    color: var(--sp-accent);
    border-color: color-mix(in oklch, var(--sp-accent) 30%, transparent);
}
.sp-chip-row {
    display: flex;
    gap: var(--sp-space-1);
    flex-wrap: wrap;
}

/* ── TILE ROW (token usage) ──────────────────────────────── */
.sp-tile-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-space-3);
}
@media (max-width: 720px) {
    .sp-tile-row { grid-template-columns: 1fr; }
}

.sp-tile {
    background: var(--sp-bg-surface-alt);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-profile-radius-sm);
    padding: var(--sp-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-1);
    min-width: 0;
    position: relative;
    transition: border-color 200ms;
}
.sp-tile:hover { border-color: var(--sp-border-strong, var(--sp-border-default, var(--sp-border-subtle))); }

.sp-tile--featured {
    background: linear-gradient(135deg,
        color-mix(in oklch, var(--sp-accent) 8%, var(--sp-bg-surface)),
        var(--sp-bg-surface-alt));
    border-color: color-mix(in oklch, var(--sp-accent) 25%, var(--sp-border-subtle));
}

.sp-tile__label {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sp-text-tertiary);
    font-weight: 700;
}

.sp-tile__value {
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--sp-text-primary);
    line-height: 1.05;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 4px 0 2px;
}

.sp-tile--featured .sp-tile__value {
    color: var(--sp-accent);
}

.sp-tile__sub {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sp-tile__sub b { color: var(--sp-text-primary); font-weight: 600; }

.sp-tile__delta {
    font-size: var(--sp-text-xs);
    color: var(--sp-color-primary, var(--sp-accent));
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-height: 1em;
}

/* ── MODEL LIST ───────────────────────────────────────────── */
.sp-modellist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sp-modellist__row {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: var(--sp-space-3);
    align-items: start;
    padding: var(--sp-space-3) 0;
    border-bottom: 1px solid var(--sp-border-subtle);
}
.sp-modellist__row:last-child { border-bottom: 0; }

.sp-modellist__rank {
    font-size: var(--sp-text-sm);
    font-weight: 700;
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
    text-align: center;
    line-height: 1.3;
    margin-top: 2px;
}

.sp-modellist__main {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.sp-modellist__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-space-2);
    min-width: 0;
}

.sp-modellist__name {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    min-width: 0;
}

.sp-modellist__share {
    font-size: var(--sp-text-sm);
    font-weight: 700;
    color: var(--sp-accent);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.sp-modellist__bar {
    display: block;
    height: 6px;
    background: var(--sp-bg-surface-alt);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--sp-border-subtle);
}

.sp-modellist__fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--sp-accent), color-mix(in oklch, var(--sp-accent) 70%, var(--sp-text-primary)));
    border-radius: inherit;
    min-width: 2px;
}

.sp-modellist__meta {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* ── AGENT LIST ───────────────────────────────────────────── */
.sp-agentlist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sp-agentlist__row {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: var(--sp-space-3);
    align-items: center;
    padding: var(--sp-space-3) 0;
    border-bottom: 1px solid var(--sp-border-subtle);
    font-size: var(--sp-text-sm);
}
.sp-agentlist__row:last-child { border-bottom: 0; }
.sp-agentlist__row[data-enabled="false"] { opacity: 0.55; }

.sp-agentlist__name {
    color: var(--sp-text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-agentlist__state {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.sp-statusdot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sp-text-tertiary);
    box-shadow: 0 0 0 2px var(--sp-bg-surface);
}
.sp-statusdot--ok {
    background: oklch(0.7 0.18 145);
    box-shadow: 0 0 0 2px var(--sp-bg-surface), 0 0 8px color-mix(in oklch, oklch(0.7 0.18 145) 40%, transparent);
}
.sp-statusdot--off {
    background: var(--sp-text-tertiary);
}

/* ── CONVERSATIONS ────────────────────────────────────────── */
.sp-conv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-space-5);
}
@media (max-width: 720px) {
    .sp-conv-grid { grid-template-columns: 1fr; gap: var(--sp-space-4); }
}

.sp-section-label {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sp-text-tertiary);
    font-weight: 700;
    margin: 0 0 var(--sp-space-2) 0;
}
.sp-section-label--rule {
    margin-top: var(--sp-space-4);
    padding-top: var(--sp-space-4);
    border-top: 1px solid var(--sp-border-subtle);
}

.sp-grouplist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.sp-grouplist li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-sm);
    padding: var(--sp-space-2) 0;
    border-bottom: 1px solid var(--sp-border-subtle);
    min-width: 0;
}
.sp-grouplist li:last-child { border-bottom: 0; }

.sp-grouplist__name {
    color: var(--sp-text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: var(--sp-text-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.sp-grouplist__meta {
    color: var(--sp-text-secondary);
    font-variant-numeric: tabular-nums;
    font-size: var(--sp-text-xs);
    white-space: nowrap;
    flex-shrink: 0;
}
.sp-grouplist__meta b { color: var(--sp-text-primary); font-weight: 700; }

.sp-conv-recent-wrap {
    overflow-x: auto;
    margin: 0 calc(-1 * var(--sp-space-5));
}

.sp-conv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--sp-text-sm);
}

.sp-conv-table th,
.sp-conv-table td {
    padding: var(--sp-space-2) var(--sp-space-3);
    text-align: left;
    vertical-align: middle;
}

.sp-conv-table th:first-child,
.sp-conv-table td:first-child { padding-left: var(--sp-space-5); }
.sp-conv-table th:last-child,
.sp-conv-table td:last-child { padding-right: var(--sp-space-5); }

.sp-conv-table th {
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sp-text-tertiary);
    font-weight: 700;
    border-bottom: 1px solid var(--sp-border-subtle);
}

.sp-conv-table tbody tr {
    border-bottom: 1px solid var(--sp-border-subtle);
    transition: background 120ms;
}
.sp-conv-table tbody tr:last-child { border-bottom: 0; }
.sp-conv-table__row:hover { background: var(--sp-bg-surface-alt); cursor: pointer; }
.sp-conv-table__row:hover .sp-conv-table__title a { color: var(--sp-accent); }

.sp-conv-table td { color: var(--sp-text-secondary); font-variant-numeric: tabular-nums; }
.sp-conv-table td:nth-child(2),
.sp-conv-table td:nth-child(3) { color: var(--sp-text-primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--sp-text-xs); }

.sp-conv-table__title a {
    color: var(--sp-text-primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 120ms;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sp-conv-table__title a code {
    font-size: var(--sp-text-xs);
    background: var(--sp-bg-surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--sp-border-subtle);
    color: var(--sp-text-secondary);
    font-weight: 500;
}
.sp-conv-table__title a:hover { color: var(--sp-accent); text-decoration: none; }
.sp-conv-table__title a:hover code { color: var(--sp-accent); border-color: color-mix(in oklch, var(--sp-accent) 30%, transparent); }

.sp-conv-table__num { text-align: right; font-weight: 600; color: var(--sp-text-primary) !important; }
.sp-conv-table__when { color: var(--sp-text-tertiary) !important; }

/* ── DEFINITION LIST ──────────────────────────────────────── */
.sp-deflist {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--sp-space-2) var(--sp-space-5);
    margin: 0;
    font-size: var(--sp-text-sm);
}

.sp-deflist dt {
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    align-self: center;
}

.sp-deflist dd {
    margin: 0;
    color: var(--sp-text-primary);
    font-variant-numeric: tabular-nums;
    align-self: center;
    min-width: 0;
}

.sp-deflist dd code,
.sp-kv__v {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: var(--sp-bg-surface-alt);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--sp-border-subtle);
    color: var(--sp-text-primary);
}
.sp-deflist__break {
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

/* ── ALLOWED MODELS DETAILS ───────────────────────────────── */
.sp-allowed-models { margin-top: var(--sp-space-3); }

.sp-allowed-models summary {
    cursor: pointer;
    font-size: var(--sp-text-sm);
    color: var(--sp-accent);
    font-weight: 600;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: var(--sp-space-1) var(--sp-space-2);
    border-radius: var(--sp-radius-md, 6px);
    transition: background 150ms;
}
.sp-allowed-models summary:hover { background: var(--sp-bg-surface-alt); }
.sp-allowed-models summary::-webkit-details-marker { display: none; }
.sp-allowed-models summary::before {
    content: "▸";
    font-size: 0.75em;
    transition: transform 150ms;
}
.sp-allowed-models[open] summary::before { transform: rotate(90deg); }

.sp-allowed-models__list {
    list-style: none;
    margin: var(--sp-space-3) 0 0;
    padding: var(--sp-space-3);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-space-1);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--sp-bg-surface-alt);
    border: 1px solid var(--sp-border-subtle);
    border-radius: var(--sp-radius-md, 6px);
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.sp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-8) var(--sp-space-5);
    text-align: center;
    color: var(--sp-text-secondary);
}

.sp-empty__icon {
    width: 32px;
    height: 32px;
    color: var(--sp-text-tertiary);
    margin-bottom: var(--sp-space-1);
}

.sp-empty p { margin: 0; font-size: var(--sp-text-sm); color: var(--sp-text-secondary); }
.sp-empty small { font-size: var(--sp-text-xs); color: var(--sp-text-tertiary); }
.sp-empty code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--sp-bg-surface-alt);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--sp-border-subtle);
    color: var(--sp-text-secondary);
    font-size: 0.95em;
}

.sp-muted {
    color: var(--sp-text-tertiary);
    font-size: var(--sp-text-sm);
    margin: 0;
    font-style: italic;
}

/* ── CARD VARIANTS ────────────────────────────────────────── */
.sp-profile-card--usage,
.sp-profile-card--conv {
    min-width: 0;
}

/* inline stat in a card header's __stats row */
.sp-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}
.sp-stat b {
    color: var(--sp-text-primary);
    font-weight: 700;
}

/* one column of the conversations grid */
.sp-conv-section {
    min-width: 0;
}

/* Admin /access/tokens — grouped table + create panel setup block */

.tokens-grouped table.data-table {
    border-collapse: collapse;
}

.tokens-grouped tbody tr.group-start > td {
    border-top: 1px solid var(--color-border, #2a2f3a);
}

.tokens-grouped td.owner-cell {
    vertical-align: middle;
    background: var(--color-surface-alt, rgba(255, 255, 255, 0.02));
    font-weight: 500;
}

.tokens-grouped td.owner-cell a {
    text-decoration: none;
}

#create-token-panel .field-hint {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--color-text-muted, rgba(255, 255, 255, 0.6));
    line-height: 1.4;
}

#create-token-panel .field-hint code {
    font-size: 0.85em;
    padding: 0 0.2rem;
}

.setup-block {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border, #2a2f3a);
    border-radius: 0.5rem;
    background: var(--color-surface-alt, rgba(255, 255, 255, 0.02));
}

.setup-block h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.setup-block .setup-intro {
    font-size: 0.9rem;
    color: var(--color-text-muted, rgba(255, 255, 255, 0.7));
    margin: 0 0 0.75rem;
    line-height: 1.5;
}

.setup-block .setup-guide-link {
    color: var(--color-primary, #4a9eff);
    text-decoration: none;
    font-weight: 500;
}

.setup-block .setup-guide-link:hover {
    text-decoration: underline;
}

.setup-block .snippet-wrap {
    position: relative;
    margin: 0.75rem 0;
}

.setup-block pre {
    background: var(--color-surface, #14171f);
    border: 1px solid var(--color-border, #2a2f3a);
    border-radius: 0.375rem;
    padding: 0.75rem 0.9rem;
    margin: 0;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.55;
}

.setup-block pre code {
    font-family: var(--font-mono, ui-monospace, monospace);
    color: var(--color-text, #e8eaed);
    white-space: pre;
}

.setup-block .btn-copy-snippet {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
}

#create-token-panel .panel-footer-state {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

#create-token-panel .panel-footer-state[hidden] {
    display: none;
}

/* Analytics → Requests (audit) table chrome: identity cell stack, the
   clickable audit rows, and the pagination footer. Markup: analytics-requests.hbs */

@layer components {

/* the toolbar already lays out via .toolbar; this is a light modifier */
.audit-toolbar {
    align-items: flex-end;
}

.audit-toolbar__count {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* identity cell — user link over a muted tenant/agent subline */
.audit-identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.audit-identity__agent {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

/* each row opens the chain-of-custody drawer */
.audit-row {
    cursor: pointer;
}
.audit-row:focus-visible {
    outline: 2px solid var(--sp-accent);
    outline-offset: -2px;
}

/* Log footer: the row range on the left, the page stepper on the right, so the
   reader can see what is on screen without counting rows. */
.audit-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-space-3);
    margin-top: var(--sp-space-4);
}

.audit-pagination__pos {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.audit-pagination__pos:first-child {
    margin-right: auto;
}

}

/* Bridge setup wizard (/bridge-setup) — numbered steps, platform download
   CTA, tabbed paste instructions, and copyable code snippets. */

@layer components {

.setup-step {
    display: grid;
    grid-template-columns: 3rem 1fr;
    gap: var(--sp-space-4);
    align-items: start;
    padding: var(--sp-space-5) 0;
    border-bottom: 1px solid var(--sp-border-subtle);
}
.setup-step:last-child { border-bottom: none; }

.setup-step .step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--sp-radius-full);
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    font-weight: 700;
    font-size: var(--sp-text-md);
}

.setup-step h2 {
    margin: 0 0 var(--sp-space-2);
    font-size: var(--sp-text-md);
    font-weight: 600;
    color: var(--sp-text-primary);
}
.setup-step p { margin: var(--sp-space-1) 0; }

.download-cta {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-2);
    padding: var(--sp-space-2) var(--sp-space-4);
    border-radius: var(--sp-radius-button);
    background: var(--sp-accent);
    color: var(--sp-text-on-accent);
    font-weight: 600;
    text-decoration: none;
    transition: filter var(--sp-duration-fast);
}
.download-cta:hover { filter: brightness(1.05); }

.download-other {
    margin-top: var(--sp-space-2);
    font-size: var(--sp-text-sm);
}
.download-other summary {
    cursor: pointer;
    color: var(--sp-text-secondary);
}
.download-other ul {
    margin: var(--sp-space-2) 0 0;
    padding-left: var(--sp-space-5);
}

/* gateway-reachability pill. Scoped to the state classes the page's JS
   sets (pending/ok/err) so it never touches the .time-range-pills .pill
   component defined in 17-contexts.css. */
.pill.pending,
.pill.ok,
.pill.err {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    padding: 0.125rem var(--sp-space-3);
    border-radius: var(--sp-radius-full);
    font-size: var(--sp-text-xs);
    font-weight: 600;
    border: 1px solid var(--sp-border-subtle);
}
.pill.ok {
    background: var(--sp-success-dim);
    color: var(--sp-success);
    border-color: color-mix(in oklch, var(--sp-success) 20%, transparent);
}
.pill.err {
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
    border-color: color-mix(in oklch, var(--sp-danger) 20%, transparent);
}
.pill.pending {
    background: var(--sp-bg-surface-raised);
    color: var(--sp-text-tertiary);
}

/* horizontal tab strip inside step 3 */
.tabs {
    display: flex;
    gap: var(--sp-space-1);
    margin: var(--sp-space-3) 0 0;
    border-bottom: 1px solid var(--sp-border-subtle);
}
.tabs button {
    background: none;
    border: none;
    padding: var(--sp-space-2) var(--sp-space-3);
    cursor: pointer;
    font: inherit;
    color: var(--sp-text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--sp-duration-fast), border-color var(--sp-duration-fast);
}
.tabs button:hover { color: var(--sp-text-primary); }
.tabs button.active {
    color: var(--sp-accent);
    border-bottom-color: var(--sp-accent);
}

.tab-panel { padding: var(--sp-space-3) 0; }
.tab-panel[hidden] { display: none; }

/* code snippet with an overlaid copy button */
.snippet { position: relative; }
.snippet pre { margin: 0; }
.snippet .copy-btn {
    position: absolute;
    top: var(--sp-space-2);
    right: var(--sp-space-2);
}

.advanced { margin-top: var(--sp-space-8); }
.advanced summary {
    cursor: pointer;
    font-weight: 600;
    padding: var(--sp-space-2) 0;
}
.advanced > div { padding: var(--sp-space-3) 0; }

}

/* Shared chrome for the trace + governance audit detail pages
   (perf-traces, governance-audit-detail). Section headers, alert banner,
   secondary table sublines, and collapsible code blocks. */

@layer components {

/* ── section header (portfolio-section) ─────────────────────── */
.portfolio-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    margin: var(--sp-space-6) 0 var(--sp-space-3);
}

.portfolio-section__title {
    margin: 0;
    font-size: var(--sp-text-md);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--sp-text-primary);
}

/* ── alert banner ───────────────────────────────────────────── */
.alert {
    padding: var(--sp-space-3) var(--sp-space-4);
    margin-bottom: var(--sp-space-5);
    background: var(--sp-bg-surface);
    border: 1px solid var(--sp-border-subtle);
    border-left: 4px solid var(--sp-text-tertiary);
    border-radius: 0 var(--sp-radius-sm) var(--sp-radius-sm) 0;
    color: var(--sp-text-secondary);
}
.alert p { margin: var(--sp-space-1) 0 0; }

.alert--danger {
    border-left-color: var(--sp-danger);
    background: var(--sp-danger-dim);
}
.alert--warning {
    border-left-color: var(--sp-warning);
    background: color-mix(in oklch, var(--sp-warning) 10%, var(--sp-bg-surface));
}

.alert__title {
    margin: 0;
    font-size: var(--sp-text-base);
    font-weight: 600;
    color: var(--sp-text-primary);
}
.alert--danger .alert__title { color: var(--sp-danger); }

/* ── Trace Explorer list table (perf-traces) ─────────────────
   Every cell is a two-line stack, so the row height is set by the stack and
   nothing may wrap: each column gets an explicit budget and clips with an
   ellipsis, with the full value on the cell's title attribute.

   Fixed layout, not auto: under auto layout a column width is only a hint that
   long content overrides, which is what pushed the status badges past the card
   edge. Fixed makes every budget below binding. Trace carries no width, so it
   absorbs whatever is left over. */
.trace-table {
    width: 100%;
    table-layout: fixed;
}

.trace-table td {
    padding: var(--sp-space-3) var(--sp-space-4);
    vertical-align: middle;
}

.trace-table th,
.trace-table td {
    white-space: nowrap;
}

.trace-table .cell-stacked > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trace-table .col-started   { width: 6.5rem; }
/* Trace takes the leftover width, but never less than this: a session id
   clipped to a few characters identifies nothing. */
.trace-table .col-trace     { min-width: 11rem; }
.trace-table .col-identity  { width: 13rem; }
.trace-table .col-model     { width: 11.5rem; }
.trace-table .col-spans     { width: 8rem; }
.trace-table .col-tokens,
.trace-table .col-cost,
.trace-table .col-duration {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.trace-table .col-tokens    { width: 8.5rem; }
.trace-table .col-cost      { width: 6rem; }
.trace-table .col-duration  { width: 8.5rem; }
.trace-table .col-status    { width: 8.5rem; }

.trace-table .col-tokens .cell-stacked,
.trace-table .col-duration .cell-stacked {
    align-items: flex-end;
}

/* The whole row is the link to the waterfall: the trace-id anchor is stretched
   over the row, so a click anywhere navigates while the link stays a real
   anchor (keyboard focus, middle-click, copy address). */
.trace-table tbody tr {
    position: relative;
}

.trace-row__id {
    text-decoration: none;
    color: var(--sp-text-primary);
}
.trace-row__id:hover { color: var(--sp-accent); }

.trace-row__id::after {
    content: "";
    position: absolute;
    inset: 0;
}

.trace-row__id:focus-visible::after {
    outline: 2px solid var(--sp-accent);
    outline-offset: -2px;
    border-radius: var(--sp-radius-sm);
}

/* The stretched link covers the row, so it also covers any tooltip under it.
   Only the cells whose truncation actually hides data — the full model name and
   the identity behind a display name — are lifted back above it; the columns
   that merely need explaining carry that on their header instead. */
.trace-table .col-identity [title],
.trace-table .col-model [title],
.trace-table .mcp-badge {
    position: relative;
    z-index: 1;
}

.trace-row__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-1);
    justify-content: flex-end;
}

.trace-table .cell-muted { color: var(--sp-text-tertiary); }

/* Narrow viewports drop the two columns a reader can recover from the detail
   page, rather than handing them a sideways scroll through all nine. The
   thresholds are viewport-wide but the table is not: the sidebar takes ~220px
   before the page gutter, so they fire earlier than the table's own width. */
@media (max-width: 1400px) {
    .trace-table .col-model { display: none; }

    /* Dropping a column is not enough on its own: the remaining budgets still
       add up past the content box, which clipped the status badges. */
    .trace-table .col-identity { width: 11rem; }
    .trace-table .col-spans    { width: 7rem; }
    .trace-table .col-tokens   { width: 7.5rem; }
    .trace-table .col-cost     { width: 5.5rem; }
    .trace-table .col-duration { width: 8rem; }
    .trace-table .col-status   { width: 7.5rem; }
}

@media (max-width: 1150px) {
    .trace-table .col-identity { display: none; }
}

/* Sortable headers: the link fills the header cell so the whole th is the
   target, matching the cursor:pointer the table has always advertised. */
.data-table th .th-sort {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-space-1);
    color: inherit;
    text-decoration: none;
}

.data-table th .th-sort:hover { color: var(--sp-text-primary); }

.data-table th:not(.sorted) .th-sort .sort-icon { opacity: 0.35; }

.data-table th:not(:has(.th-sort)) { cursor: default; }

/* ── collapsible code block (transcript / chain dumps) ──────── */
.code-collapsible summary {
    cursor: pointer;
    font-size: var(--sp-text-sm);
    font-weight: 600;
    color: var(--sp-accent);
    padding: var(--sp-space-1) 0;
}
.code-collapsible .code-block {
    margin-top: var(--sp-space-2);
    max-height: 480px;
    overflow: auto;
}

}

/* Evals page: share bars in the distribution tables, and the scored-answer
   cards with their per-dimension meters. Markup: evals.hbs, eval-run-detail.hbs */

@layer components {

.eval-section-title {
    margin: var(--sp-space-6) 0 var(--sp-space-3);
    font-size: var(--sp-text-lg);
    font-weight: 600;
}

.eval-hint {
    margin: 0 0 var(--sp-space-2);
}

.eval-notice {
    margin: 0 0 var(--sp-space-3);
    padding: var(--sp-space-2) var(--sp-space-3);
    border-left: 3px solid var(--sp-accent);
    background: var(--sp-bg-surface-raised);
    font-size: var(--sp-text-sm);
}

.eval-notice--error {
    border-left-color: var(--sp-danger);
}

/* count over a proportional bar, so a table column reads as a distribution */
.eval-share {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    min-width: 4rem;
}

.eval-share__count {
    font-variant-numeric: tabular-nums;
}

.eval-share__bar {
    display: block;
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: var(--sp-border-subtle);
    position: relative;
}

.eval-share__bar::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--v, 0%);
    border-radius: 2px;
    background: var(--sp-accent);
}

.eval-score {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.eval-topic {
    display: block;
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
}

.eval-topic__sample {
    display: block;
    margin-top: 2px;
}

/* run launchers sit side by side and wrap on narrow viewports */
/* Each tab carries the one form that launches its own kind of run, under the
   heading that names it — so the form no longer needs a label of its own. */
.eval-run-form,
.eval-filter-form {
    align-items: flex-end;
    flex-wrap: wrap;
}

.eval-run-form__number {
    width: 6rem;
}

/* one card per scored answer */
.eval-results {
    display: flex;
    flex-direction: column;
    gap: var(--sp-space-3);
}

.eval-result {
    padding: var(--sp-space-3);
    border: 1px solid var(--sp-border-default);
    border-left-width: 3px;
    border-radius: var(--sp-radius-md);
    background: var(--sp-bg-surface);
}

.eval-result--partial {
    border-left-color: var(--sp-warning);
}

.eval-result--fail {
    border-left-color: var(--sp-danger);
}

.eval-result__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
}

.eval-result__score {
    font-size: var(--sp-text-lg);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.eval-result__link {
    font-size: var(--sp-text-xs);
}

.eval-result__rationale {
    margin: var(--sp-space-2) 0 0;
    font-size: var(--sp-text-sm);
    line-height: 1.5;
}

.eval-result__detail {
    margin-top: var(--sp-space-2);
    font-size: var(--sp-text-xs);
}

.eval-result__detail summary {
    cursor: pointer;
    color: var(--sp-text-tertiary);
}

.eval-result__excerpt {
    margin: var(--sp-space-2) 0 0;
    color: var(--sp-text-secondary);
    word-break: break-word;
}

.eval-result__promote {
    display: flex;
    gap: var(--sp-space-2);
    margin-top: var(--sp-space-3);
}

.eval-result__promote .search-input {
    flex: 1 1 auto;
}

.eval-flag {
    padding: 1px 6px;
    border-radius: var(--sp-radius-sm);
    background: var(--sp-border-subtle);
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-xs);
    font-family: var(--sp-font-mono);
}

/* per-dimension meters — same 1-5 scale as the headline score */
.eval-dims {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-3);
    margin-top: var(--sp-space-2);
}

.eval-dim {
    display: flex;
    align-items: center;
    gap: var(--sp-space-1);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.eval-dim__bar {
    display: block;
    width: 3rem;
    height: 3px;
    border-radius: 2px;
    background: var(--sp-border-subtle);
    position: relative;
}

.eval-dim__bar::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--v, 0%);
    border-radius: 2px;
    background: var(--sp-accent);
}

.eval-dim__label {
    white-space: nowrap;
}

.eval-dim__score {
    font-variant-numeric: tabular-nums;
}

/* a timestamp does not fit at the KPI value size */
.kpi-card__value--sm {
    font-size: var(--sp-text-sm);
}

}

@layer components {
/* Demo trace: the governed-agent timeline at /admin/demo/trace.
   The page is read as a story, so the styling groups events into turns and
   makes a denial the loudest thing on the screen. */

.trace-sessions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-space-2);
    margin-bottom: var(--sp-space-4);
}

.trace-session {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: var(--sp-space-2) var(--sp-space-3);
    border: 1px solid var(--sp-border-subtle);
    border-radius: 0 0.375rem 0.75rem 0;
    background: var(--sp-bg-surface);
    color: inherit;
    text-decoration: none;
    transition: border-color var(--sp-duration-normal), box-shadow var(--sp-duration-normal);
}

.trace-session:hover {
    border-color: var(--sp-border-strong);
    box-shadow: var(--sp-shadow-card);
}

.trace-session.is-active {
    border-color: var(--sp-primary);
    box-shadow: var(--sp-shadow-card);
}

.trace-session__when {
    font-weight: 600;
    font-size: var(--sp-text-sm);
}

.trace-session__model {
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
}

.trace-session__counts {
    display: flex;
    gap: var(--sp-space-2);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.trace-session__allow {
    color: var(--sp-success);
}

.trace-session__deny {
    color: var(--sp-danger);
}

.trace-session__calls {
    color: var(--sp-text-tertiary);
}

.trace-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-space-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-space-4);
    color: var(--sp-text-secondary);
    font-size: var(--sp-text-sm);
}

.trace-legend p {
    margin: 0;
    max-width: 70ch;
}

.trace-turn {
    margin-bottom: var(--sp-space-5);
}

.trace-turn__header {
    display: flex;
    align-items: center;
    gap: var(--sp-space-2);
    flex-wrap: wrap;
    padding: var(--sp-space-2) var(--sp-space-3);
    background: var(--sp-bg-card-header);
    border: 1px solid var(--sp-border-subtle);
    border-bottom: none;
    border-radius: 0 var(--sp-radius-brand-tr) 0 0;
}

.trace-turn--blocked .trace-turn__header {
    border-left: 3px solid var(--sp-danger);
}

.trace-turn__ordinal {
    font-weight: 700;
    font-size: var(--sp-text-sm);
}

.trace-turn__prompt {
    font-family: var(--sp-font-mono);
    font-size: var(--sp-text-xs);
    color: var(--sp-text-secondary);
}

.trace-turn__spacer {
    flex: 1 1 auto;
}

.trace-turn__count {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
}

.trace-turn .table-container {
    border-radius: 0 0 0.75rem 0;
}

.trace-row {
    cursor: pointer;
}

.trace-row--deny > td:first-child {
    box-shadow: inset 3px 0 0 var(--sp-danger);
}

/* The four governance policies, shown in the order they ran. A stage the
   pipeline skipped is dimmed rather than hidden: "we never got that far" is
   itself the answer to why a call was blocked. */
.trace-stages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.trace-stage {
    padding: 0.0625rem 0.375rem;
    border-radius: 0.25rem;
    font-family: var(--sp-font-mono);
    font-size: 0.6875rem;
    border: 1px solid transparent;
    white-space: nowrap;
}

.trace-stage__name {
    font-size: inherit;
}

.trace-stage--pass {
    background: var(--sp-success-dim);
    color: var(--sp-success);
}

.trace-stage--fail {
    background: var(--sp-danger-dim);
    color: var(--sp-danger);
    font-weight: 700;
}

.trace-stage--skip {
    background: var(--sp-bg-tertiary);
    color: var(--sp-text-tertiary);
    opacity: 0.7;
}

.trace-detail {
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    max-width: 46ch;
}

}

/* Inference Requests tabs: the per-tab section wrapper, the breakdown share
   bars, and the section caption shared by the breakdown tables.
   Markup: analytics-requests.hbs + partials/components/breakdown-table.hbs */

@layer components {

/* Each tab renders inside one of these. It also keeps the tables off
   .admin-main's direct-child flex rules, so a tab's content is laid out by the
   section rather than stretched to fill the viewport column. */
.requests-section {
    display: block;
    margin-bottom: var(--sp-space-8);
}

.section-caption {
    margin: 0 0 var(--sp-space-4);
    font-size: var(--sp-text-sm);
    color: var(--sp-text-secondary);
    max-width: 68ch;
}

/* Share column: a bar and its percentage on one line, so the eye can rank rows
   without reading the numbers. */
.data-table th.col-share {
    width: 12rem;
    min-width: 9rem;
}

.data-table td.col-share {
    display: table-cell;
    white-space: nowrap;
}

.share-bar {
    display: inline-block;
    width: 6.5rem;
    height: 0.5rem;
    margin-right: var(--sp-space-2);
    vertical-align: middle;
    border-radius: var(--sp-radius-sm);
    background:
        linear-gradient(
            to right,
            var(--sp-chart-blue) var(--v, 0%),
            transparent var(--v, 0%)
        ),
        color-mix(in oklch, var(--sp-warm-900) 6%, transparent);
}

.share-bar__value {
    font-size: var(--sp-text-xs);
    color: var(--sp-text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* A breakdown row is a link into the log; the whole row lifts on hover so the
   affordance does not depend on hitting the key text exactly. */
.breakdown-row:hover td {
    background: var(--sp-accent-dim);
}

.breakdown-row__key {
    text-decoration: none;
}

.breakdown-row__key:hover {
    text-decoration: underline;
}

.breakdown-row--errors .share-bar {
    background:
        linear-gradient(
            to right,
            var(--sp-danger) var(--v, 0%),
            transparent var(--v, 0%)
        ),
        color-mix(in oklch, var(--sp-warm-900) 6%, transparent);
}

}
