/* CSS Variables für konsistentes Cyberpunk Design */
:root {
    /* Layout — topbar height; referenced by sticky-table-thead to avoid overlap */
    --top-nav-height: 52px;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius — use Aurora tokens: --r-sm, --r-md, --r-lg */
    --border-radius-sm: var(--r-sm);
    --border-radius-lg: var(--r-lg);
}

/* Reset und Basis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Global Keyboard Focus Indicators - WCAG 2.1 AA Compliant */
/* Focus-visible only shows when keyboard navigating, not on mouse clicks */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* Remove outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast focus for dark mode */
[data-theme="dark"] *:focus-visible {
    outline-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(var(--tone-cyan-rgb), 0.4);
}

/* Specific focus styles for buttons */
.btn:focus-visible,
button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

[data-theme="dark"] .btn:focus-visible,
[data-theme="dark"] button:focus-visible {
    outline-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Enhanced focus for form inputs to override default */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--primary) !important;
    outline-offset: 2px;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-tint), 0 0 10px var(--primary-glow), 0 0 20px var(--primary-tint);
}

[data-theme="dark"] input:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] textarea:focus-visible {
    outline-color: var(--primary) !important;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(var(--tone-cyan-rgb), 0.4);
}

/* Link focus indicators */
a:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    text-decoration: underline;
    text-decoration-color: var(--primary);
    text-decoration-thickness: 2px;
}

[data-theme="dark"] a:focus-visible {
    outline-color: var(--primary);
    text-decoration-color: var(--primary);
}

/* Focus for custom checkbox/radio inputs */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

[data-theme="dark"] input[type="checkbox"]:focus-visible,
[data-theme="dark"] input[type="radio"]:focus-visible {
    outline-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(var(--tone-cyan-rgb), 0.4);
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--fg);
    background-color: var(--bg);
    font-size: 16px;
}

/* Skip Links for Accessibility - WCAG 2.4.1 */
.skip-link {
    position: absolute;
    top: -50px;
    left: 0;
    background: var(--primary-strong); /* High contrast blue - WCAG AAA compliant */
    color: var(--on-primary);
    padding: var(--spacing-sm) var(--spacing-lg);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 0 0 8px;
    z-index: calc(var(--z-turbo-bar) + 10);
    box-shadow: 0 4px 12px rgb(0, 0, 0, 0.3); /* design-spec: singular strong shadow for badge/indicator */
    transition: top 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    opacity: 0;
    pointer-events: none;
}

.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    opacity: 1;
    pointer-events: auto;
    outline: 4px solid var(--warning); /* Gold outline for high visibility */
    outline-offset: 2px;
    box-shadow: 0 6px 20px rgb(var(--primary-rgb), 0.5),
                0 0 0 4px rgb(var(--warning-rgb), 0.3);
}

.skip-link:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgb(var(--primary-rgb), 0.6);
}

/* Dark mode support for skip links */
[data-theme="dark"] .skip-link {
    background: var(--primary); /* Lighter blue for dark mode */
    color: var(--on-primary);
}

[data-theme="dark"] .skip-link:focus,
[data-theme="dark"] .skip-link:focus-visible {
    outline-color: var(--warning);
    box-shadow: 0 6px 20px rgb(var(--primary-rgb), 0.6),
                0 0 0 4px rgb(var(--warning-rgb), 0.3);
}

[data-theme="dark"] .skip-link:hover {
    background: var(--primary);
}

/* Header - Cyberpunk Style with Dark Mode Support */
/* FairyAurora v3.0 Topbar — slim 52px height, Aurora-Palette */
.header {
    background: var(--surface);
    color: var(--fg);
    padding: 0 var(--spacing-lg);
    min-height: 52px;
    box-shadow: 0 1px 0 var(--border);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
}

@media (min-width: 768px) {
    .header {
        position: sticky;
        top: 0;
        z-index: var(--z-sticky);
    }
}

[data-theme="dark"] .header {
    background: var(--surface);
    border-bottom-color: var(--border);
}

/* ============================================
   Cyberpunk Fairy - Automation Magic Effects
   Subtle, professional with a wink 😉
   ============================================ */

/* Container glow - subtle shimmer effect */
.fairy-magic-glow {
    position: relative;
    box-shadow:
        inset 0 0 0 1px var(--accent-tint),
        0 0 20px var(--accent-tint);
    border-radius: var(--r-md);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fairy-magic-glow::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        transparent 40%,
        var(--accent-tint) 50%,
        transparent 60%
    );
    background-size: 200% 200%;
    animation: fairy-shimmer 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 0; /* local stacking-context */
}

.fairy-magic-glow:hover {
    box-shadow:
        inset 0 0 0 1px var(--accent-tint),
        0 0 30px var(--accent-glow),
        0 0 10px var(--primary-tint);
    transform: translateY(-1px);
}

/* Icon sparkle - elegant pulse, not hyperactive */
.fairy-icon-sparkle {
    color: var(--accent);
    display: inline-block;
    animation: fairy-pulse 2.5s ease-in-out infinite;
}

.fairy-icon-sparkle::after {
    content: " ✨";
    font-size: 0.7em;
    opacity: 0.8;
}

/* Badge - refined, not too flashy */
.fairy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: linear-gradient(135deg,
        var(--accent) 0%,
        var(--accent-glow) 100%);
    color: var(--on-accent);
    border-radius: var(--r-pill);
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    box-shadow: 0 2px 8px var(--accent-tint);
    border: none;
    transition: all 0.2s ease;
}

.fairy-badge:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.fairy-badge::before {
    content: "✦";
    font-size: 0.9em;
}

/* Automatic field indicator - subtle left border accent */
.fairy-field-automatic {
    position: relative;
    border-left: 3px solid var(--accent) !important;
    background: linear-gradient(
        90deg,
        var(--accent-tint) 0%,
        transparent 30%
    ) !important;
    transition: all 0.2s ease;
}

.fairy-field-automatic:focus {
    border-left-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Helper text for automatic fields */
.fairy-helper {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.25rem;
    opacity: 0.85;
}

.fairy-helper::before {
    content: "✦";
    font-size: 0.65rem;
}

/* Tooltip for magic explanation - used for auto-filled fields */
.fairy-tooltip {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
    color: var(--accent);
    transition: color 0.2s ease;
}

.fairy-tooltip:hover {
    color: var(--accent);
}

.fairy-tooltip::after {
    content: "✦ " attr(data-fairy-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    color: var(--fg);
    padding: 0.5rem 0.75rem;
    padding-top: 0.625rem;
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    max-width: 280px;
    white-space: normal;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow:
        0 4px 12px rgb(0, 0, 0, 0.2), /* design-spec: tooltip drop shadow composite */
        0 0 0 1px var(--accent-tint);
    z-index: var(--z-dropdown);
}

/* Pink accent line at top */
.fairy-tooltip::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    width: 60%;
    max-width: 100px;
    height: 2px;
    transform: translateX(-50%);
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent) 20%,
        var(--accent) 80%,
        transparent 100%
    );
    border-radius: 1px; /* design-spec: hairline mini-radius */
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

/* Arrow (separate element needed) */
.fairy-tooltip-arrow {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--surface);
}

.fairy-tooltip:hover::after,
.fairy-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Dark mode enhancement */
[data-theme="dark"] .fairy-tooltip::after {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    box-shadow:
        0 4px 16px rgb(0, 0, 0, 0.4), /* design-spec: tooltip dark-mode elevated shadow composite */
        0 0 0 1px var(--accent-tint);
}

/* Bootstrap Tooltip - Subtle fairy shimmer on appear */
.tooltip.show .tooltip-inner {
    animation: fairy-tooltip-appear 0.6s ease-out;
}

@keyframes fairy-tooltip-appear {
    0% {
        box-shadow: 0 0 12px var(--accent-glow);
    }
    100% {
        box-shadow: none;
    }
}

/* Reduced motion - no shimmer */
@media (prefers-reduced-motion: reduce) {
    .tooltip.show .tooltip-inner {
        animation: none;
    }
}

/* 12. Audit Log - Fresh entries glow */
.fairy-fresh-entry {
    animation: fairy-fresh-appear 2s ease-out;
}

@keyframes fairy-fresh-appear {
    0% {
        background-color: var(--accent-tint);
        box-shadow: inset 0 0 20px var(--accent-tint);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* Timestamp sparkle for very fresh entries (< 5 min) */
.fairy-timestamp-fresh {
    position: relative;
    color: var(--accent);
}

.fairy-timestamp-fresh::after {
    content: "✦";
    position: absolute;
    top: -2px;
    right: -12px;
    font-size: 0.6rem;
    color: var(--accent);
    animation: fairy-sparkle 2s ease-in-out infinite;
}

/* Slightly stale but still recent (5-30 min) */
.fairy-timestamp-recent {
    position: relative;
}

.fairy-timestamp-recent::after {
    content: "·";
    position: absolute;
    top: 0;
    right: -8px;
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
    .fairy-fresh-entry {
        animation: none;
        background-color: var(--accent-tint);
    }
    .fairy-timestamp-fresh::after {
        animation: none;
    }
}

/* 13. Session Timeout - Gentle reminder glow */
.fairy-session-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
    opacity: 0;
    transition: opacity 0.5s ease;
    box-shadow: inset 0 0 100px transparent;
}

.fairy-session-warning-active {
    opacity: 1;
    animation: fairy-session-pulse 4s ease-in-out infinite;
}

@keyframes fairy-session-pulse {
    0%, 100% {
        box-shadow: inset 0 0 60px var(--accent-tint);
    }
    50% {
        box-shadow: inset 0 0 100px var(--accent-tint);
    }
}

.fairy-session-warning-fade {
    opacity: 0;
    animation: none;
}

/* Alert/Notification with fairy touch */
.fairy-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(
        135deg,
        var(--accent-tint) 0%,
        var(--accent-tint) 100%
    );
    border: 1px solid var(--accent-tint);
    border-radius: var(--r-md);
    color: var(--fg);
}

.fairy-alert-icon {
    font-size: 1.25rem;
    color: var(--accent);
    animation: fairy-pulse 2.5s ease-in-out infinite;
}

.fairy-alert-content {
    flex: 1;
}

.fairy-alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--accent);
}

/* Dark Mode - Enhanced visibility */
[data-theme="dark"] .fairy-field-automatic {
    background: linear-gradient(
        90deg,
        var(--accent-tint) 0%,
        transparent 30%
    ) !important;
}

[data-theme="dark"] .fairy-magic-glow {
    box-shadow:
        inset 0 0 0 1px var(--accent-tint),
        0 0 25px var(--accent-glow);
}

[data-theme="dark"] .fairy-alert {
    background: linear-gradient(
        135deg,
        var(--accent-tint) 0%,
        var(--accent-tint) 100%
    );
    border-color: var(--accent-tint);
}

/* Animations - Smooth and subtle */
@keyframes fairy-shimmer {
    0% { background-position: 200% 200%; }
    100% { background-position: -200% -200%; }
}

@keyframes fairy-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

@keyframes fairy-sparkle {
    0%, 100% {
        filter: drop-shadow(0 0 8px var(--accent-glow));
        opacity: 1;
    }
    50% {
        filter: drop-shadow(0 0 12px var(--accent-glow))
                drop-shadow(0 0 4px var(--primary-glow));
        opacity: 0.85;
    }
}

/* Reduced motion - Respect user preferences */
@media (prefers-reduced-motion: reduce) {
    .fairy-magic-glow::before,
    .fairy-icon-sparkle,
    .fairy-alert-icon {
        animation: none;
    }
}

/* ============================================
   Fairy Magic - Contextual Patterns
   For specific use cases in the application
   ============================================ */

/* 1. Smart Insights - Suggestion indicator */
.fairy-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: linear-gradient(
        135deg,
        var(--accent-tint) 0%,
        var(--primary-tint) 100%
    );
    border: 1px dashed var(--accent-tint);
    border-radius: var(--r-md);
    font-size: 0.8125rem;
    color: var(--fg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.fairy-suggestion:hover {
    background: linear-gradient(
        135deg,
        var(--accent-tint) 0%,
        var(--primary-tint) 100%
    );
    border-color: var(--accent-glow);
    transform: translateY(-1px);
}

.fairy-suggestion-icon {
    color: var(--accent);
    animation: fairy-pulse 2.5s ease-in-out infinite;
}

.fairy-suggestion-text {
    flex: 1;
}

.fairy-suggestion-action {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* 2. Workflow Magic - Auto-transition effect */
.fairy-workflow-magic {
    position: relative;
    overflow: hidden;
}

.fairy-workflow-magic::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--accent-tint),
        var(--primary-tint),
        transparent
    );
    animation: fairy-workflow-sweep 1.5s ease-out forwards;
}

@keyframes fairy-workflow-sweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

.fairy-workflow-complete {
    animation: fairy-workflow-pulse 0.6s ease-out;
}

@keyframes fairy-workflow-pulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* 3. Bulk Actions - Completion feedback */
.fairy-bulk-complete {
    animation: fairy-bulk-flash 0.8s ease-out;
}

@keyframes fairy-bulk-flash {
    0% { background-color: var(--accent-tint); }
    100% { background-color: transparent; }
}

.fairy-bulk-bar {
    background: linear-gradient(
        90deg,
        var(--bg) 0%,
        var(--accent-tint) 50%,
        var(--bg) 100%
    );
    border: 1px solid var(--accent-tint);
}

.fairy-bulk-action {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--brand-gradient);
    color: var(--on-primary);
    border: none;
    border-radius: var(--r-pill);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fairy-bulk-action:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.fairy-bulk-action::before {
    content: "✦";
    font-size: 0.9em;
}

/* 4. Search/Command Palette - Priority highlighting */
.fairy-search-priority {
    position: relative;
    border-left: 2px solid var(--accent);
    background: linear-gradient(
        90deg,
        var(--accent-tint) 0%,
        transparent 50%
    );
}

.fairy-search-priority::after {
    content: "✦ Priorisiert";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: var(--accent);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 5. Onboarding - Guided highlights */
.fairy-onboarding-highlight {
    position: relative;
    z-index: var(--z-overlay); /* local stacking-context (onboarding highlight) */
    animation: fairy-onboarding-glow 2s ease-in-out infinite;
}

@keyframes fairy-onboarding-glow {
    0%, 100% {
        box-shadow:
            0 0 0 4px var(--accent-tint),
            0 0 20px var(--accent-tint);
    }
    50% {
        box-shadow:
            0 0 0 6px var(--accent-tint),
            0 0 30px var(--accent-glow);
    }
}

.fairy-onboarding-step {
    position: absolute;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--r-pill);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgb(0, 0, 0, 0.3); /* design-spec: singular strong shadow for badge/indicator */
}

.fairy-onboarding-step::before {
    content: "✦";
}

/* 6. Auto-Correct - Field correction feedback */
.fairy-auto-correct {
    animation: fairy-correct-flash 0.5s ease-out;
}

@keyframes fairy-correct-flash {
    0% {
        background-color: var(--accent-tint);
        border-color: var(--accent);
    }
    100% {
        background-color: transparent;
    }
}

.fairy-corrected-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: var(--accent);
    margin-left: 0.5rem;
    opacity: 0;
    animation: fairy-fade-in 0.3s ease-out forwards;
}

@keyframes fairy-fade-in {
    0% { opacity: 0; transform: translateY(-5px); }
    100% { opacity: 0.85; transform: translateY(0); }
}

.fairy-corrected-indicator::before {
    content: "✦";
    font-size: 0.6rem;
}

/* Dark Mode - Contextual patterns */
[data-theme="dark"] .fairy-suggestion {
    background: linear-gradient(
        135deg,
        var(--accent-tint) 0%,
        var(--primary-tint) 100%
    );
}

[data-theme="dark"] .fairy-search-priority {
    background: linear-gradient(
        90deg,
        var(--accent-tint) 0%,
        transparent 50%
    );
}

[data-theme="dark"] .fairy-bulk-bar {
    background: linear-gradient(
        90deg,
        var(--surface-2) 0%,
        var(--accent-tint) 50%,
        var(--surface-2) 100%
    );
}

/* 7. Empty States - Ghost-Writer Fee */
/* Applied to existing .empty-state component for subtle magic */
.empty-state {
    position: relative;
}

.empty-state::before {
    content: "\2726"; /* ✦ Unicode star */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    opacity: 0.035;
    color: var(--accent);
    pointer-events: none;
    z-index: 0; /* local stacking-context */
}

.empty-state-icon,
.empty-state .empty-state-icon {
    position: relative;
    z-index: 1; /* local stacking-context */
}

.empty-state-icon i {
    color: var(--fg-3);
    opacity: 0.5;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.empty-state:hover .empty-state-icon i {
    color: var(--accent);
    opacity: 0.7;
}

.empty-state-title {
    position: relative;
    z-index: 1; /* local stacking-context */
}

.empty-state-description {
    position: relative;
    z-index: 1; /* local stacking-context */
}

/* Explicit fairy class for more prominent styling */
.fairy-empty-state {
    position: relative;
    text-align: center;
    padding: 3rem 2rem;
    color: var(--fg-3);
}

.fairy-empty-state::before {
    opacity: 0.05;
}

/* 8. Filter Hint - Smart Reset Nudge */
.fairy-filter-hint {
    animation: fairy-filter-pulse 2s ease-in-out infinite;
}

@keyframes fairy-filter-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 transparent;
    }
    50% {
        box-shadow: 0 0 0 4px var(--accent-tint);
    }
}

.fairy-filter-hint::after {
    content: "✦";
    margin-left: 0.375rem;
    font-size: 0.8em;
    color: var(--accent);
    animation: fairy-sparkle 1.5s ease-in-out infinite;
}

@keyframes fairy-sparkle {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* 9. Upload Success - Glow-up Animation */
.fairy-upload-success {
    animation: fairy-upload-glow 2.5s ease-out forwards;
}

@keyframes fairy-upload-glow {
    0% {
        background-color: var(--accent-tint);
        box-shadow: 0 0 20px var(--accent-glow);
    }
    70% {
        background-color: var(--accent-tint);
        box-shadow: 0 0 10px var(--accent-tint);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

/* 10. Transition Success - One-time magic flash */
.fairy-transition-success {
    animation: fairy-magic-sweep 0.8s ease-out forwards;
}

@keyframes fairy-magic-sweep {
    0% {
        background: linear-gradient(
            90deg,
            transparent 0%,
            var(--accent-tint) 50%,
            transparent 100%
        );
        background-size: 200% 100%;
        background-position: -100% 0;
    }
    50% {
        background-position: 100% 0;
    }
    100% {
        background: transparent;
    }
}

/* 11. Toast/Notification - Fairy accent */
.fairy-toast {
    border-left: 3px solid var(--accent);
    position: relative;
    overflow: hidden;
}

.fairy-toast::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--accent),
        var(--accent),
        var(--accent)
    );
    background-size: 200% 100%;
    animation: fairy-toast-shimmer 2s linear infinite;
}

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

/* Reduced motion - disable all fairy animations */
@media (prefers-reduced-motion: reduce) {
    .fairy-empty-state::before,
    .fairy-filter-hint,
    .fairy-filter-hint::after,
    .fairy-upload-success,
    .fairy-transition-success,
    .fairy-toast::before {
        animation: none;
    }

    .fairy-filter-hint::after {
        display: none;
    }
}

/* FairyAurora v3.0: alte .header h1 + .header p entfernt —
   Brand-Component (templates/_components/_brand.html.twig) rendert jetzt
   Logo + Name + Version im Header. */

/* Mobile Menu Button - Hidden on Desktop */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: calc(var(--z-fixed) + 1); /* 501 - above sidebar, below modals */
    position: relative;
}

.mobile-menu-btn span {
    width: 100%;
    height: 2px;
    background: var(--fg);
    border-radius: var(--r-sm);
    transition: transform var(--t-base) var(--ease-out),
                opacity var(--t-fast) var(--ease-out);
}

/* Hamburger Animation */
.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile only */
@media (max-width: 767.98px) {
    .mobile-menu-btn {
        display: flex;
        margin-right: var(--spacing-md);
    }
}

/* Sidebar Backdrop - Mobile only */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: color-mix(in oklab, var(--bg) 70%, transparent);
    backdrop-filter: blur(4px); /* iOS Safari blur effect */
    backdrop-filter: blur(4px);
    z-index: calc(var(--z-fixed) - 1); /* 499 - below sidebar, above page content */
    opacity: 0;
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
    will-change: opacity;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* App Layout with Sidebar */
.app-layout {
    display: flex;
    min-height: calc(100vh - 180px);
}

/* App Sidebar - FairyAurora v3.0 (224px per Design-System-Spec) */
.app-sidebar {
    width: 224px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--spacing-lg) 0;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    z-index: var(--z-sticky);
}

/* Custom Scrollbar for Sidebar - Light Mode */
.app-sidebar::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: rgb(0, 0, 0, 0.05); /* design-spec: scrollbar track faint tint */
    border-radius: var(--r-sm);
    margin: var(--spacing-sm) 0;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgb(0, 0, 0, 0.2); /* design-spec: scrollbar thumb / submenu overlay tint */
    border-radius: var(--r-sm);
    transition: all 0.3s ease;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgb(0, 0, 0, 0.3); /* design-spec: scrollbar thumb hover strong tint */
}

.app-sidebar::-webkit-scrollbar-thumb:active {
    background: rgb(0, 0, 0, 0.4); /* design-spec: scrollbar thumb active tint */
}

/* Firefox Scrollbar */
.app-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgb(0, 0, 0, 0.2) rgb(0, 0, 0, 0.05); /* design-spec: Firefox scrollbar thumb / track */
}

/* Dark Mode Sidebar */
[data-theme="dark"] .app-sidebar,
[data-bs-theme="dark"] .app-sidebar {
    background: linear-gradient(180deg, var(--bg) 0%, var(--surface) 50%, var(--bg) 100%);
    border-right: 3px solid transparent;
    border-image: linear-gradient(
  180deg,
  var(--primary) 0%,
  var(--accent) 50%,
  var(--primary) 100%
) 1;
    box-shadow: 2px 0 30px var(--primary-tint),
                inset -1px 0 20px var(--primary-tint);
}

/* Dark Mode Scrollbar */
[data-theme="dark"] .app-sidebar::-webkit-scrollbar-track,
[data-bs-theme="dark"] .app-sidebar::-webkit-scrollbar-track {
    background: linear-gradient(180deg,
                rgb(15, 23, 42, 0.3),
                rgb(30, 41, 59, 0.5),
                rgb(15, 23, 42, 0.3));
}

[data-theme="dark"] .app-sidebar::-webkit-scrollbar-thumb,
[data-bs-theme="dark"] .app-sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
                var(--primary) 0%,
                var(--accent) 50%,
                var(--accent) 100%);
    border: 1px solid var(--primary-tint);
    box-shadow: 0 0 15px var(--primary-glow),
                inset 0 0 10px rgb(255, 255, 255, 0.1);
}

[data-theme="dark"] .app-sidebar::-webkit-scrollbar-thumb:hover,
[data-bs-theme="dark"] .app-sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg,
                var(--primary) 0%,
                var(--accent) 50%,
                var(--accent-hover) 100%);
    box-shadow: 0 0 20px var(--primary-glow),
                0 0 10px var(--accent-glow),
                inset 0 0 15px rgb(255, 255, 255, 0.2);
    border-color: var(--primary-glow);
}

[data-theme="dark"] .app-sidebar::-webkit-scrollbar-thumb:active,
[data-bs-theme="dark"] .app-sidebar::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg,
                var(--primary-hover) 0%,
                var(--accent) 50%,
                var(--accent-hover) 100%);
    box-shadow: 0 0 25px var(--primary-glow),
                0 0 15px var(--accent-glow);
}

[data-theme="dark"] .app-sidebar,
[data-bs-theme="dark"] .app-sidebar {
    scrollbar-color: var(--primary) rgb(15, 23, 42, 0.5);
}

.app-sidebar nav:not(#main-navigation) {
    padding: 0 var(--spacing-xs);
}

.app-sidebar ul:not(.mega-menu-categories, .mega-menu-links) {
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-sidebar li:not(.mega-menu-category) {
    margin: 0;
}

/* Sidebar Dividers - Light Mode */
.app-sidebar .nav-divider {
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-sm);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--fg-3); /* Using CSS var */
    letter-spacing: 1.5px;
    margin-top: var(--spacing-xl);
    border-left: 0;
    position: relative;
    user-select: none;
}

.app-sidebar .nav-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 60%;
    transform: translateY(-50%);
    background: var(--primary);
    border-radius: var(--r-sm);
}

.app-sidebar .nav-divider:first-child {
    margin-top: 0;
}

/* Dark Mode Dividers */
[data-theme="dark"] .app-sidebar .nav-divider,
[data-bs-theme="dark"] .app-sidebar .nav-divider {
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow),
                 0 0 5px var(--primary-glow);
}

[data-theme="dark"] .app-sidebar .nav-divider::before,
[data-bs-theme="dark"] .app-sidebar .nav-divider::before {
    background: linear-gradient(180deg,
                transparent,
                var(--primary-glow),
                transparent);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Sidebar Links - Light Mode */
.app-sidebar nav:not(#main-navigation) a {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0.75rem var(--spacing-md);
    margin: 0.25rem var(--spacing-sm);
    min-height: 44px; /* WCAG touch target minimum */
    color: var(--fg); /* Using CSS var */
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--r-sm);
    border-left: 0;
    position: relative;
    overflow: hidden;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    touch-action: manipulation; /* Disable double-tap zoom */
}

.app-sidebar nav:not(#main-navigation) a i {
    font-size: 1.15rem;
    min-width: 24px;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 3px var(--primary-tint));
}

.app-sidebar nav:not(#main-navigation) a span {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Link Hover Effect - Subtle Glow */
.app-sidebar nav:not(#main-navigation) a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg,
                var(--primary-tint),
                var(--accent-tint),
                transparent);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--r-sm);
}

.app-sidebar nav:not(#main-navigation) a::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar nav:not(#main-navigation) a:hover::before {
    width: 100%;
}

.app-sidebar nav:not(#main-navigation) a:hover::after {
    background: linear-gradient(180deg, var(--primary), var(--accent));
    box-shadow: 0 0 10px var(--primary-glow);
}

.app-sidebar nav:not(#main-navigation) a:hover {
    color: white; /* design-spec: text on primary-tint sidebar hover with dark text-shadow */
    background: var(--primary-tint);
    padding-left: calc(var(--spacing-md) + 4px);
    text-shadow: 0 0 10px var(--primary-glow);
    transform: translateX(2px);
}

.app-sidebar nav:not(#main-navigation) a:hover i {
    color: var(--primary);
    transform: scale(1.12) rotate(-5deg);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.app-sidebar nav:not(#main-navigation) a:hover span {
    letter-spacing: 0.5px;
}

/* Sidebar Active Link - Bold Gradient */
.app-sidebar nav:not(#main-navigation) a.active {
    /* WCAG AA: Solid gradient background ensures 4.5:1 contrast with white text */
    background: linear-gradient(135deg,
                var(--primary-tint) 0%,
                var(--accent-tint) 100%),
                linear-gradient(rgb(0, 0, 0, 0.4), rgb(0, 0, 0, 0.4)); /* design-spec: sidebar active-link WCAG contrast multiply overlay */

    background-blend-mode: normal, multiply;
    color: white; /* design-spec: text on dark multiply-blend gradient active link */
    padding-left: calc(var(--spacing-md) + 4px);
    box-shadow: 0 2px 15px var(--primary-tint),
                inset 0 1px 0 rgb(255, 255, 255, 0.1);
    text-shadow: 0 1px 3px rgb(0, 0, 0, 0.8), /* design-spec: text on dark gradient active link */
                 0 0 15px var(--primary-glow);
    font-weight: 600;
    border: 1px solid var(--primary-tint);
}

.app-sidebar nav:not(#main-navigation) a.active::before {
    width: 100%;
    background: linear-gradient(90deg,
                var(--primary-tint),
                var(--accent-tint),
                transparent);
}

.app-sidebar nav:not(#main-navigation) a.active::after {
    background: linear-gradient(180deg, var(--primary), var(--accent), var(--accent));
    width: 4px;
    box-shadow: 0 0 15px var(--primary-glow),
                0 0 10px var(--accent-glow);
}

.app-sidebar nav:not(#main-navigation) a.active i {
    color: var(--primary);
    transform: scale(1.2);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.app-sidebar nav:not(#main-navigation) a.active span {
    letter-spacing: 0.5px;
}

/* Focus State for Accessibility */
.app-sidebar nav:not(#main-navigation) a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

[data-theme="dark"] .app-sidebar nav:not(#main-navigation) a {
    color: var(--fg-2);
}

[data-theme="dark"] .app-sidebar nav:not(#main-navigation) a:hover {
    color: white; /* design-spec: text on primary-tint dark-mode sidebar hover */
}

[data-theme="dark"] .app-sidebar nav:not(#main-navigation) a.active {
    /* WCAG AA: Enhanced contrast in dark mode */
    background: linear-gradient(135deg,
                var(--primary-tint) 0%,
                var(--accent-tint) 100%),
                linear-gradient(rgb(0, 0, 0, 0.3), rgb(0, 0, 0, 0.3)); /* design-spec: dark-mode sidebar active-link WCAG contrast multiply overlay */

    background-blend-mode: normal, multiply;
    color: white; /* design-spec: text on dark multiply-blend gradient dark-mode active link */
    text-shadow: 0 1px 3px rgb(0, 0, 0, 0.9), /* design-spec: text on dark gradient dark-mode active link */
                 0 0 15px rgb(var(--tone-cyan-rgb), 0.6);
}

/* Sidebar Submenu (Expandable Navigation) */
.app-sidebar .has-submenu {
    position: relative;
}

.app-sidebar .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-sidebar .submenu-toggle .submenu-icon {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

.app-sidebar .submenu-toggle .submenu-icon.rotated {
    transform: rotate(180deg);
}

.app-sidebar .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgb(0, 0, 0, 0.2); /* design-spec: scrollbar thumb / submenu overlay tint */
    margin: 0 var(--spacing-xs);
    border-radius: var(--r-sm);
}

.app-sidebar .submenu.expanded {
    max-height: 500px;
}

.app-sidebar .submenu li {
    margin: 0;
}

.app-sidebar .submenu a {
    padding: 0.5rem var(--spacing-md) 0.5rem calc(var(--spacing-md) + 8px);
    margin: 0.15rem var(--spacing-xs);
    font-size: 0.8rem;
}

.app-sidebar .submenu a i {
    font-size: 0.95rem;
    min-width: 20px;
}

.app-sidebar .submenu a span {
    font-size: 0.8rem;
}

.app-sidebar .submenu-divider {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 1px;
    opacity: 0.8;
    user-select: none;
    border-top: 1px solid var(--primary-tint);
    margin-top: var(--spacing-xs);
}

.app-sidebar .submenu-divider:first-child {
    border-top: none;
    margin-top: 0;
}

.app-sidebar .badge-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: var(--r-sm);
    margin-left: auto;
    min-width: 14px;
    height: 14px;
}

.app-sidebar .badge-mini.badge-danger {
    background: rgb(var(--danger-rgb), 0.8);
    color: var(--on-danger);
    box-shadow: 0 0 8px rgb(var(--danger-rgb), 0.5);
}

.app-sidebar .framework-link {
    position: relative;
}

.app-sidebar .framework-link::before {
    display: none;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Container & Content with Dark Mode Support */
.container {
    max-width: 1600px;  /* Increased from 1400px for better use of modern displays */
    margin: var(--spacing-xl) auto;
    padding: 0 var(--spacing-xl);
}

.content {
    background: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    animation: fadeIn var(--t-slow) var(--ease-out);
}

[data-theme="dark"] .content {
    background: var(--surface);
    color: var(--fg);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typography with Dark Mode Support */
h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--fg);
    margin-bottom: var(--spacing-lg);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--fg);
    margin-top: var(--spacing-2xl);
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: var(--spacing-md);
}

/* Cards - Cyberpunk Style with Dark Mode Support */
/* ============================================================
   Card Component System - Standardized
   Based on UI/UX Audit Issue 3.1
   ============================================================ */

/* Base Card (Bootstrap compatible) */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--t-base) var(--ease-out);
    position: relative;
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

/* Card Header */
.card-header {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.card-header h5,
.card-header h4,
.card-header h3 {
    margin: 0;
    font-weight: 600;
    color: var(--fg);
}

.card-header h5 i,
.card-header h4 i,
.card-header h3 i {
    margin-right: 0.5rem;
    color: var(--primary);
}

/* Card Actions (header buttons) */
.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Card Body */
.card-body {
    padding: var(--spacing-lg);
}

/* Card Footer */
.card-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* Dark Mode */
[data-theme="dark"] .card {
    background: var(--surface);
    border-color: var(--border);
    color: var(--fg);
}

[data-theme="dark"] .card-header {
    background: var(--bg);
    border-bottom-color: var(--border);
}

[data-theme="dark"] .card-footer {
    background: var(--surface-2);
    border-top-color: var(--border);
}

/* Hoverable Card Variant */
.card-hoverable {
    cursor: pointer;
}

.card-hoverable::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--accent));
    opacity: 0;
    transition: opacity var(--t-base) var(--ease-out);
}

.card-hoverable:hover::before {
    opacity: 1;
}

.card-hoverable:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card:hover {
    box-shadow: var(--shadow-lg),
                0 0 25px var(--primary-glow),
                0 0 15px var(--accent-tint),
                0 0 10px var(--accent-tint);
    transform: translateY(-4px);
    border-color: var(--primary);
    animation: card-glow 2s ease-in-out infinite;
}

@keyframes card-glow {
    0%, 100% {
        box-shadow: var(--shadow-lg),
                    0 0 25px var(--primary-glow),
                    0 0 15px var(--accent-tint),
                    0 0 10px var(--accent-tint);
    }
    50% {
        box-shadow: var(--shadow-lg),
                    0 0 30px var(--primary-glow),
                    0 0 20px var(--accent-glow),
                    0 0 15px var(--accent-tint);
    }
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin: var(--spacing-xl) 0;
}

.kpi-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--t-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    box-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-tint);
}

.kpi-card:hover {
    box-shadow: var(--shadow-lg),
                0 0 20px var(--primary-glow),
                0 0 10px var(--accent-tint);
    transform: translateY(-6px) scale(1.02);
}

.kpi-card .icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
    opacity: 0.9;
}

.kpi-card .label {
    color: var(--fg-2);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card .value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--fg);
    line-height: 1;
}

.kpi-card .unit {
    color: var(--fg-3);
    font-size: 1.2rem;
    font-weight: 500;
    margin-left: var(--spacing-xs);
}

/* Module Grid */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--spacing-lg);
    margin: var(--spacing-xl) 0;
}

.module-card {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--spacing-lg);
    transition: all var(--t-base) var(--ease-out);
    background: var(--surface);
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
    border-color: var(--primary);
}

.module-card h3 {
    margin-bottom: var(--spacing-sm);
    color: var(--fg);
}

.module-card p {
    color: var(--fg-2);
    margin-bottom: var(--spacing-md);
}

/* Buttons - Cyberpunk Style */
/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* Spinner - Bootstrap-like */
.spinner-border {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: -0.125em;
    border: 0.15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border-spin 0.75s linear infinite;
}

.spinner-border-sm {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 0.125em;
}

@keyframes spinner-border-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Spacing helper for spinner */
.me-2 {
    margin-right: 0.5rem;
}

/* @deprecated — use _fa_alert.html.twig component instead. Kept for PDF/email backward compat. */
/* Info/Warning Boxes */
.info-box,
.warning-box,
.success-box,
.danger-box {
    padding: var(--spacing-md);
    border-radius: var(--r-md);
    margin: var(--spacing-md) 0;
    border-left: 4px solid;
}

.info-box {
    background-color: var(--primary-tint);
    border-color: var(--primary);
    color: var(--fg);
}

.warning-box {
    background-color: rgb(var(--warning-rgb), 0.1);
    border-color: var(--warning);
    color: var(--fg);
}

.success-box {
    background-color: rgb(var(--success-rgb), 0.1);
    border-color: var(--success);
    color: var(--fg);
}

.danger-box {
    background-color: rgb(var(--danger-rgb), 0.1);
    border-color: var(--danger);
    color: var(--fg);
}

/* Tables with Dark Mode Support */
.table-container {
    overflow-x: auto;
    margin: var(--spacing-xl) 0;
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

[data-theme="dark"] table {
    background: var(--surface);
    color: var(--fg);
}

thead {
    background-color: var(--fg);
    color: var(--surface-2);
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 2px 0 rgb(var(--bs-primary-rgb), 0.3);
}

[data-theme="dark"] thead {
    background-color: var(--surface-2);
    border-bottom-color: var(--border);
    color: var(--fg);
}

thead th {
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

[data-theme="dark"] thead th {
    color: var(--fg);
}

tbody {
    background-color: var(--bg);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color var(--t-fast) var(--ease-out);
    background-color: var(--bg);
}

[data-theme="dark"] tbody {
    background-color: var(--surface);
}

[data-theme="dark"] tbody tr {
    border-bottom-color: var(--border);
    background-color: var(--surface);
}

tbody tr:hover {
    background-color: var(--bg);
}

[data-theme="dark"] tbody tr:hover {
    background-color: var(--surface-2);
}

tbody td {
    padding: var(--spacing-md);
    color: var(--fg);
}

[data-theme="dark"] tbody td {
    color: var(--fg);
}

/* Sticky Table Headers */
.table thead.sticky-top,
.table thead.thead-sticky {
    position: sticky;
    top: var(--top-nav-height, 52px); /* sticks just below the .header topbar */
    z-index: var(--z-sticky);
    box-shadow: var(--bs-box-shadow);
}

.table thead.sticky-top th,
.table thead.thead-sticky th {
    background-color: var(--fg);
    color: var(--surface-2);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    padding: 0.75rem var(--spacing-sm);
    white-space: nowrap;
}

[data-theme="dark"] .table thead.sticky-top th,
[data-theme="dark"] .table thead.thead-sticky th {
    background-color: var(--surface-2);
    color: var(--fg);
}

[data-theme="dark"] .table thead.sticky-top,
[data-theme="dark"] .table thead.thead-sticky {
    box-shadow: var(--bs-box-shadow-lg);
}

/* Table container for scrollable tables */
.table-container {
    position: relative;
    max-height: 800px;
    overflow-y: auto;
    margin-top: 1rem;
}

/* ==========================================
   BADGES - Standardized Badge System
   ==========================================

   Badge Categories:
   1. STATUS BADGES - Use Bootstrap 5 syntax: badge bg-{color}
   2. SEVERITY BADGES - Risk/Vulnerability levels: badge-{severity}
   3. ACTION BADGES - Audit log actions (already in ui-components.css)
   4. SPECIAL BADGES - Custom use cases

   Bootstrap 5 Status Badges (bg-success, bg-warning, etc.) are provided by Bootstrap.
   We only add dark mode support and severity variants here.
   ========================================== */

.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.badge-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-lg {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgb(0, 0, 0, 0.1); /* design-spec: badge-lg singular subtle shadow */
}

/* Badge spacing utilities */
.badge + .badge {
    margin-left: 0.25rem;
}

/* Icon in badge spacing */
.badge .bi {
    margin-right: 0.25rem;
}

.badge .bi:only-child {
    margin-right: 0;
}

/* SEVERITY BADGES - For Risks, Vulnerabilities, Incidents (WCAG AA Compliant) */
.badge-critical {
    /* Already WCAG AA compliant: 4.83:1 contrast */
    background: linear-gradient(135deg, var(--danger), var(--danger-strong));
    color: var(--on-danger);
    font-weight: 600;
    box-shadow: 0 2px 4px rgb(var(--danger-rgb), 0.3);
    text-shadow: 0 1px 2px rgb(0, 0, 0, 0.6); /* design-spec: text on colored badge for WCAG AA contrast */
}

.badge-high {
    /* WCAG AA: Dark overlay improves contrast from 2.80:1 to 4.5:1 */
    background: linear-gradient(135deg, var(--warning-strong), var(--danger)),
                linear-gradient(rgb(0, 0, 0, 0.25), rgb(0, 0, 0, 0.25)); /* design-spec: badge-high WCAG contrast multiply overlay */

    background-blend-mode: normal, multiply;
    color: var(--on-danger);
    font-weight: 600;
    box-shadow: 0 2px 4px var(--warning-glow);
    text-shadow: 0 1px 2px rgb(0, 0, 0, 0.7); /* design-spec: text on badge-high for WCAG AA contrast */
}

.badge-medium {
    /* Already WCAG AA compliant with dark text on amber */
    background: linear-gradient(135deg, var(--warning), var(--warning-strong));
    color: var(--on-warning);
    font-weight: 600;
    box-shadow: 0 2px 4px var(--warning-glow);
    text-shadow: 0 1px 1px rgb(255, 255, 255, 0.3);
}

.badge-low {
    /* WCAG AA: Dark overlay improves contrast from 3.68:1 to 4.5:1 */
    background: linear-gradient(135deg, var(--primary), var(--primary-hover)),
                linear-gradient(rgb(0, 0, 0, 0.2), rgb(0, 0, 0, 0.2)); /* design-spec: badge-low WCAG contrast multiply overlay */

    background-blend-mode: normal, multiply;
    color: var(--on-primary);
    font-weight: 600;
    box-shadow: 0 2px 4px var(--primary-glow);
    text-shadow: 0 1px 2px rgb(0, 0, 0, 0.6); /* design-spec: text on colored badge for WCAG AA contrast */
}

/* SPECIAL BADGES */
.badge-neutral {
    background: var(--bg);
    color: var(--fg-2);
    border: 1px solid var(--border);
}

/* Forms with Dark Mode Support */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--fg);
}

[data-theme="dark"] .form-label {
    color: var(--fg);
}

/* Required Field Indicator */
.form-label .required,
.required-indicator {
    color: var(--danger);
    margin-left: 0.25rem;
    font-weight: 700;
}

[data-theme="dark"] .form-label .required,
[data-theme="dark"] .required-indicator {
    color: var(--danger);
}

/* Required Field Legend */
.form-required-legend {
    font-size: 0.875rem;
    color: var(--fg-3);
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-left: 3px solid var(--danger);
    border-radius: var(--r-sm);
}

.form-required-legend .required {
    color: var(--danger);
    font-weight: 700;
    margin-right: 0.25rem;
}

[data-theme="dark"] .form-required-legend {
    background: var(--surface-2);
}

/* ==========================================
   FIELDSET STYLING - Issues 2.1 & 2.3
   Semantic form sections with card-like appearance
   ========================================== */

/* Fieldset base styling - looks like card */
fieldset {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0;
    margin-bottom: 1rem;
    background: var(--surface);
}

/* Fieldset legend - looks like card header */
fieldset legend {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    margin: 0;
    width: 100%;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    color: var(--fg);
    float: none;  /* Override browser default */
}

/* Content padding inside fieldset */
fieldset > .row,
fieldset > div:not(legend) {
    padding: 1rem;
}

/* Dark Mode support for fieldsets */
[data-theme="dark"] fieldset {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] fieldset legend {
    background: var(--bg);
    border-bottom-color: var(--border);
    color: var(--fg);
}

/* Nested rows inside fieldset don't need extra padding */
fieldset .row .row {
    padding: 0;
}

/* NIS2 Fieldset - Special Warning Styling */
fieldset.nis2-fieldset {
    border-color: var(--warning);
}

fieldset.nis2-fieldset legend.nis2-legend {
    background: var(--warning) !important;
    color: var(--on-warning) !important;
    border-bottom-color: var(--warning-strong);
}

[data-theme="dark"] fieldset.nis2-fieldset {
    border-color: var(--warning);
}

[data-theme="dark"] fieldset.nis2-fieldset legend.nis2-legend {
    background: var(--warning) !important;
    color: var(--on-warning) !important;
    border-bottom-color: var(--warning-strong);
}

/* Invalid Field Feedback - Consistent Positioning */
.invalid-feedback,
.form-error,
.error-message {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--danger);
    font-weight: 500;
    line-height: 1.4;
    position: relative;
    padding-left: 1.5rem;
}

/* Always show error if it has d-block class */
.invalid-feedback.d-block,
.form-error.d-block {
    display: block;
}

/* Show error when field is invalid */
.is-invalid ~ .invalid-feedback,
.is-invalid ~ .form-error,
.has-error .invalid-feedback,
.has-error .form-error {
    display: block;
}

/* Error icon positioning */
.invalid-feedback i,
.form-error i {
    position: absolute;
    left: 0;
    top: 0.1rem;
}

/* Invalid field styling */
.form-control.is-invalid,
.form-select.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--danger);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23ef4444' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgb(var(--danger-rgb), 0.2);
}

[data-theme="dark"] .invalid-feedback,
[data-theme="dark"] .form-error {
    color: var(--danger);
}

[data-theme="dark"] .form-control.is-invalid,
[data-theme="dark"] .form-select.is-invalid,
[data-theme="dark"] input.is-invalid,
[data-theme="dark"] select.is-invalid,
[data-theme="dark"] textarea.is-invalid {
    border-color: var(--danger);
}

/* ==========================================
   FORM PLACEHOLDER TEXT - WCAG AA Compliant
   ========================================== */

/* Light mode: Darker placeholder for 4.5:1 contrast */
input::placeholder,
textarea::placeholder,
.form-control::placeholder,
.form-select::placeholder {
    color: var(--fg-2); /* Darkened placeholder for 4.76:1 contrast */
    opacity: 1;
}

/* Dark mode: Lighter placeholder maintained in dark-mode.css */

/* Valid Field Feedback */
.valid-feedback {
    display: none;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--success);
}

.is-valid ~ .valid-feedback {
    display: block;
}

.form-control.is-valid {
    border-color: var(--success);
}

/* Aurora v4: .form-control base + dark-theme + :focus rules moved to
   fairy-aurora-components.css (form-control bridge). app.css legacy rules
   had redundant tokens + a gradient-on-focus background that clashed with
   the fa-cyber-input frame-owned focus-glow.

   Retained only: textarea min-height (ergonomic tweak, not theme-related) */
textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Progress Bar - Cyberpunk Style */
.progress {
    height: 24px;
    background-color: var(--surface-3);
    border-radius: var(--r-sm);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgb(0,0,0,0.3); /* design-spec: progress bar inset depth */
    border: 1px solid var(--primary-tint);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, var(--accent) 100%);
    transition: width var(--t-slow) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--surface);
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-tint);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgb(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Progress Fill Color Variants */
.progress-fill-mini.progress-success {
    background: var(--success) !important;
}

.progress-fill-mini.progress-warning {
    background: var(--warning) !important;
}

.progress-fill-mini.progress-danger {
    background: var(--danger) !important;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.stat-item {
    padding: var(--spacing-md);
    background: var(--surface-2);
    border-radius: var(--r-sm);
    border-left: 3px solid var(--primary);
}

.stat-item strong {
    display: block;
    color: var(--fg);
    margin-bottom: var(--spacing-xs);
}

/* Loading Spinner - Cyberpunk Fairy Style */
.spinner {
    border: 3px solid var(--primary-tint);
    border-top: 3px solid var(--primary);
    border-right: 3px solid var(--accent);
    border-bottom: 3px solid var(--accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-tint);
    position: relative;
}

.spinner::after {
    content: '✨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Language Switcher - Cyberpunk Style */
.language-switcher {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--primary-tint);
    padding: var(--spacing-xs);
    border-radius: var(--r-sm);
    border: 1px solid var(--primary-tint);
    box-shadow: inset 0 0 10px var(--primary-tint);
}

.lang-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    color: var(--surface);
    text-decoration: none;
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--t-base) var(--ease-out);
    opacity: 0.7;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.lang-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary-tint), transparent);
    transition: left 0.5s;
}

.lang-btn:hover::before {
    left: 100%;
}

.lang-btn:hover {
    opacity: 1;
    background: var(--primary-tint);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow),
                inset 0 0 10px var(--primary-tint);
    text-shadow: 0 0 5px var(--primary-glow);
}

.lang-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    opacity: 1;
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--primary-glow),
                0 0 10px var(--accent-glow),
                inset 0 0 10px rgb(255, 255, 255, 0.1);
    text-shadow: 0 0 8px rgb(255, 255, 255, 0.5);
}

/* Detail Grid - Structured Label-Value Display */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.detail-item .label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.detail-item .value {
    font-size: 1rem;
    color: var(--fg);
    word-break: break-word;
}

.detail-item .value:empty::after {
    content: '—';
    color: var(--fg-3);
}

.detail-section {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--primary-tint);
}

.detail-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: var(--spacing-md);
}

/* Detail Item with Data Reuse indicator */
.detail-item.fairy-data-reuse .label::after {
    content: ' ✦';
    color: var(--accent);
    font-size: 0.75rem;
}

.detail-item.fairy-data-reuse .value {
    position: relative;
}

/* User Menu Dropdown — FairyAurora v3.0 Pill-Avatar */
.user-menu {
    position: relative;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-decoration: none;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease-out),
                box-shadow var(--t-fast) var(--ease-out),
                transform var(--t-fast) var(--ease-out);
}

.user-avatar:hover,
.user-avatar:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    transform: translateY(-1px);
}

/* FairyAurora v3.0: User-Dropdown nutzt fa-dropdown-panel-Pattern;
   Visibility wird via hidden-Attribut vom aurora-dropdown-Stimulus-Controller
   gesteuert (nicht mehr hover/focus-within). */
.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 240px;
    z-index: var(--z-dropdown);
}
.user-dropdown[hidden] { display: none !important; }

.user-dropdown-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    background: var(--primary-tint);
}

.user-dropdown-name {
    display: block;
    font-weight: 600;
    color: var(--fg);
    font-size: 0.9375rem;
}

.user-dropdown-email {
    display: block;
    font-size: 0.8125rem;
    color: var(--fg-2);
    opacity: 0.8;
}

.user-dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: var(--spacing-xs) 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--fg);
    text-decoration: none;
    transition: all var(--t-fast) var(--ease-out);
}

.user-dropdown-item i {
    width: 1.25rem;
    text-align: center;
    color: var(--primary);
}

.user-dropdown-item:hover {
    background: var(--primary-tint);
    color: var(--primary);
}

/* Fairy Logout - The magic goodbye */
.fairy-logout {
    position: relative;
}

.fairy-logout-sparkle {
    opacity: 0;
    color: var(--accent);
    margin-left: auto;
    transition: all 0.3s ease;
    transform: scale(0.5);
}

.fairy-logout:hover {
    background: linear-gradient(90deg,
        var(--accent-tint),
        var(--accent-tint));
    color: var(--accent);
}

.fairy-logout:hover i {
    color: var(--accent);
    animation: fairy-wave 0.6s ease;
}

.fairy-logout:hover .fairy-logout-sparkle {
    opacity: 1;
    transform: scale(1);
    animation: fairy-sparkle-bye 1s ease infinite;
}

@keyframes fairy-wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

@keyframes fairy-sparkle-bye {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
    .fairy-logout:hover i,
    .fairy-logout:hover .fairy-logout-sparkle {
        animation: none;
    }

    .fairy-logout-sparkle {
        opacity: 1;
        transform: scale(1);
    }
}

/* Footer with Dark Mode Support */
.footer {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--fg-2);
    margin-top: var(--spacing-2xl);
    background: linear-gradient(180deg, transparent, var(--primary-tint));
    position: relative;
}
.footer::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg,
                  transparent,
                  var(--primary-tint),
                  var(--accent-tint),
                  var(--accent-tint),
                  transparent);
    pointer-events: none;
}

[data-theme="dark"] .footer {
    color: var(--fg-2);
    background: linear-gradient(180deg, transparent, var(--primary-tint));
}

.footer p {
    margin: var(--spacing-xs) 0;
}

.footer kbd {
    background: linear-gradient(135deg, var(--primary-tint), var(--accent-tint));
    border: 1px solid var(--primary-tint);
    padding: 0.125rem 0.375rem;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    box-shadow: 0 0 5px var(--primary-tint);
}

.footer a {
    color: var(--primary);
    transition: all var(--t-base) var(--ease-out);
}

.footer a:hover {
    color: var(--accent);
    text-shadow: 0 0 8px var(--primary-glow);
}

/* Utility Classes */
/* Screen Reader Only - WCAG 2.1 Compliant */
.sr-only,
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focusable screen reader text */
.sr-only-focusable:focus,
.visually-hidden-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

.d-flex { display: flex; }
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Responsive */
/* Mobile (up to 768px) - Hide Sidebar, show mobile menu */
@media (max-width: 767.98px) {
    .header {
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: 64px;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .header p {
        font-size: 0.75rem;
    }

    .header-logo img {
        width: 32px;
        height: 32px;
    }

    .header-logo {
        gap: 0.5rem;
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.75rem;
    }

    .user-dropdown {
        min-width: 200px;
        right: -0.5rem;
    }

    .notification-bell-btn-header {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Hide sidebar on mobile by default */
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: var(--z-fixed);
        transform: translateX(-100%);
        transition: transform var(--t-base) var(--ease-out);
        box-shadow: 5px 0 30px rgb(0, 0, 0, 0.15); /* design-spec: mobile sidebar slide-in edge shadow */
        will-change: transform;
        contain: layout style paint;
        -webkit-overflow-scrolling: touch;
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    /* Pull-revealing state (visual feedback while dragging) */
    .app-sidebar.pull-revealing {
        transition: none; /* Disable transition during drag */
        will-change: transform;
    }

    .app-layout {
        flex-direction: column;
    }

    .app-main {
        width: 100%;
    }

    .container {
        padding: 0 var(--spacing-sm);
        margin: var(--spacing-md) auto;
    }

    .content {
        padding: var(--spacing-sm);
    }

    .kpi-grid,
    .module-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.5rem;
    }
}

/* Tablet (769px to 1024px) - Narrower Sidebar */
@media (min-width: 768px) and (max-width: 1024px) {
    .app-sidebar {
        width: 220px;
    }

    .app-sidebar a {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.85rem;
    }

    .app-sidebar a i {
        font-size: 1rem;
    }

    .container {
        padding: 0 var(--spacing-md);
    }
}

/* Large Desktop (> 1440px) - Wider Sidebar */
@media (min-width: 1440px) {
    .app-sidebar {
        width: 300px;
    }

    .app-sidebar a {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 1rem;
    }
}

/* ===============================
   Dashboard Widget Sizing
   =============================== */
.widget-size-small {
    flex: 0 0 calc(25% - 15px);
    max-width: calc(25% - 15px);
}

.widget-size-medium {
    flex: 0 0 calc(50% - 15px);
    max-width: calc(50% - 15px);
}

.widget-size-large {
    flex: 0 0 calc(75% - 15px);
    max-width: calc(75% - 15px);
}

.widget-size-full {
    flex: 0 0 100%;
    max-width: 100%;
}

/* Responsive widget sizes */
@media (max-width: 767.98px) {
    .widget-size-small,
    .widget-size-medium,
    .widget-size-large,
    .widget-size-full {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Widget drag state */
.widget.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.widget.drag-over {
    border: 2px dashed var(--primary);
    background: var(--primary-tint);
}

/* ============================================================
   Real-time Validation & Feedback Styles
   ============================================================ */

/* Field wrapper for feedback icon positioning */
.field-with-feedback {
    position: relative;
}

/* Validation feedback icons (checkmark and X) */
.validation-feedback-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 5; /* local stacking-context */
    font-size: 1.25rem;
    transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
    animation: feedbackAppear 0.2s ease-out;
}

@keyframes feedbackAppear {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Adjust icon position for input groups */
.input-group .field-with-feedback .validation-feedback-icon {
    right: -35px;
}

/* Valid field styling with checkmark */
.form-control.is-valid,
.form-select.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: var(--success);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-valid:focus,
input.is-valid:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 0.2rem rgb(var(--success-rgb), 0.25);
}

/* Valid feedback message */
.valid-feedback {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--success);
    font-weight: 500;
    line-height: 1.4;
}

.valid-feedback.d-block {
    display: block;
}

.is-valid ~ .valid-feedback {
    display: block;
}

/* Dark mode adjustments */
[data-theme="dark"] .invalid-feedback,
[data-theme="dark"] .form-error {
    color: var(--danger);
}

[data-theme="dark"] .valid-feedback {
    color: var(--success);
}

[data-theme="dark"] .form-control.is-invalid,
[data-theme="dark"] input.is-invalid {
    border-color: var(--danger);
}

[data-theme="dark"] .form-control.is-valid,
[data-theme="dark"] input.is-valid {
    border-color: var(--success);
}

/* ============================================================
   Password Strength Indicator
   ============================================================ */

.password-strength-meter {
    margin-top: 0.75rem;
}

.password-strength-meter .progress {
    height: 6px;
    border-radius: var(--r-sm);
    background-color: var(--surface-3);
    overflow: hidden;
}

[data-theme="dark"] .password-strength-meter .progress {
    background-color: var(--surface-3);
}

.password-strength-meter .progress-bar {
    transition: width 0.3s ease, background-color 0.3s ease;
}

.password-strength-meter small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.4;
}

/* Strength level colors */
.password-strength-meter .bg-danger {
    background-color: var(--danger) !important;
}

.password-strength-meter .bg-warning {
    background-color: var(--warning) !important;
}

.password-strength-meter .bg-info {
    background-color: var(--primary) !important;
}

.password-strength-meter .bg-success {
    background-color: var(--success) !important;
}

/* Dark mode strength colors */
[data-theme="dark"] .password-strength-meter .bg-danger {
    background-color: var(--danger) !important;
}

[data-theme="dark"] .password-strength-meter .bg-warning {
    background-color: var(--warning) !important;
}

[data-theme="dark"] .password-strength-meter .bg-info {
    background-color: var(--primary) !important;
}

[data-theme="dark"] .password-strength-meter .bg-success {
    background-color: var(--success) !important;
}

/* ============================================================
   Unique Field Validation (AJAX Loading)
   ============================================================ */

.unique-check-spinner {
    display: none;
    color: var(--primary);
    z-index: var(--z-popover); /* local stacking-context */
}

.unique-check-spinner .spinner-icon {
    animation: spin 1s linear infinite;
    font-size: 1.25rem;
}

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

/* Adjust field padding when spinner is visible */
.field-with-feedback:has(.unique-check-spinner[style*="display: block"]) input,
.field-with-feedback:has(.unique-check-spinner[style*="display: block"]) .form-control {
    padding-right: calc(2.5em + 0.75rem);
}

/* ===================================================================
   Mobile Table Responsiveness - Issue 12.2
   Auto-wrap all tables in responsive containers on mobile devices
   =================================================================== */
@media (max-width: 767.98px) {
    /* Make tables scrollable on mobile */
    table:not(.no-mobile-scroll) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        max-width: 100%;
    }

    /* Ensure table headers stay visible during scroll */
    table:not(.no-mobile-scroll) thead {
        position: sticky;
        left: 0;
        z-index: 1; /* local stacking-context */
    }

    /* Minimum column width on mobile */
    table:not(.no-mobile-scroll) td,
    table:not(.no-mobile-scroll) th {
        min-width: 100px;
        white-space: nowrap;
    }

    /* Allow text wrapping for specific columns */
    table:not(.no-mobile-scroll) td.wrap,
    table:not(.no-mobile-scroll) th.wrap {
        white-space: normal;
        min-width: 150px;
    }
}

/* Dark mode adjustments for sticky headers */
[data-theme="dark"] table thead {
    background-color: var(--surface-2);
}

/* ===================================================================
   Table Styling Standardization - Issue 4.1
   Default styling for all tables to ensure consistency
   =================================================================== */

/* Base table styling - applies to ALL tables unless overridden */
table:not(.no-default-style) {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--fg);
    border-collapse: collapse;
    background-color: var(--bg);
}

table:not(.no-default-style) th,
table:not(.no-default-style) td {
    padding: 0.75rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg);
}

[data-theme="dark"] table:not(.no-default-style) td,
[data-theme="dark"] table:not(.no-default-style) th,
[data-bs-theme="dark"] table:not(.no-default-style) td,
[data-bs-theme="dark"] table:not(.no-default-style) th {
    background-color: var(--surface) !important;
    color: var(--fg) !important;
}

table:not(.no-default-style) thead th {
    vertical-align: bottom;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    color: var(--surface-2);
    background-color: var(--fg);
}

[data-theme="dark"] table:not(.no-default-style) thead th {
    color: var(--fg);
    background-color: var(--surface-2);
}

table:not(.no-default-style) tbody tr:hover {
    background-color: var(--bg);
}

[data-theme="dark"] table:not(.no-default-style) tbody tr:hover,
[data-bs-theme="dark"] table:not(.no-default-style) tbody tr:hover {
    background: var(--surface-2) !important;
}

[data-theme="dark"] table:not(.no-default-style) tbody tr:hover td,
[data-bs-theme="dark"] table:not(.no-default-style) tbody tr:hover td {
    color: var(--fg) !important;
    background-color: var(--surface-2) !important;
}

/* Fix text-muted in tables for dark mode */
[data-theme="dark"] table:not(.no-default-style) .text-muted,
[data-theme="dark"] table:not(.no-default-style) small.text-muted {
    color: var(--fg-3) !important; /* readable muted text */
}

/* Ensure strong/bold text is highly visible in dark mode tables */
[data-theme="dark"] table:not(.no-default-style) strong,
[data-theme="dark"] table:not(.no-default-style) b,
[data-theme="dark"] table:not(.no-default-style) td strong,
[data-theme="dark"] table:not(.no-default-style) td b,
[data-theme="dark"] table tbody td strong,
[data-theme="dark"] table tbody td b {
    color: var(--fg) !important; /* high contrast text */
    font-weight: 600;
    opacity: 1 !important;
}

/* Striped tables */
table.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bs-table-striped-bg);
}

[data-theme="dark"] table.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bs-table-striped-bg);
}

/* Bordered tables */
table.table-bordered th,
table.table-bordered td {
    border: 1px solid var(--border);
}

/* Small/compact tables */
table.table-sm th,
table.table-sm td {
    padding: 0.3rem 0.5rem;
    font-size: 0.875rem;
}

/* Borderless tables */
table.table-borderless th,
table.table-borderless td {
    border: none;
}

/* Table inside cards - no extra margin */
.card table:last-child,
.info-box table:last-child {
    margin-bottom: 0;
}


/* ===================================================================
   Utility Classes - Issue 7.1
   Replace common inline styles with reusable CSS classes
   =================================================================== */

/* Height Utilities */
.h-10px { height: 10px; }
.h-20px { height: 20px; }
.h-25px { height: 25px; }
.h-30px { height: 30px; }
.h-40px { height: 40px; }
.h-50px { height: 50px; }

/* Width Utilities (percentages) */
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-60 { width: 60%; }
.w-70 { width: 70%; }
.w-80 { width: 80%; }
.w-90 { width: 90%; }
.w-auto { width: auto; }

/* Font Size Utilities */
.fs-8pt { font-size: 8pt; }
.fs-9pt { font-size: 9pt; }
.fs-10pt { font-size: 10pt; }
.fs-11pt { font-size: 11pt; }
.fs-12pt { font-size: 12pt; }

/* Common spacing utilities (if not in Bootstrap) */
.mt-2rem { margin-top: 2rem; }
.mb-2rem { margin-bottom: 2rem; }
.mt-3rem { margin-top: 3rem; }
.mb-3rem { margin-bottom: 3rem; }

/* Display utilities (complement Bootstrap) */
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex-row { display: flex; flex-direction: row; }
.d-flex-col { display: flex; flex-direction: column; }

/* Flex utilities */
.flex-align-center { align-items: center; }
.flex-justify-center { justify-content: center; }
.flex-gap-xs { gap: 0.25rem; }
.flex-gap-sm { gap: 0.5rem; }
.flex-gap-md { gap: 0.625rem; }
.flex-gap-lg { gap: 1rem; }

/* Cursor utilities */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Square icon size */
.icon-20 {
    width: 20px;
    height: 20px;
    display: inline-block;
    flex-shrink: 0;
}

.icon-24 {
    width: 24px;
    height: 24px;
    display: inline-block;
    flex-shrink: 0;
}

.icon-32 {
    width: 32px;
    height: 32px;
    display: inline-block;
    flex-shrink: 0;
}

/* White space utilities */
.ws-nowrap { white-space: nowrap; }
.ws-normal { white-space: normal; }
.ws-pre-wrap { white-space: pre-wrap; }

/* Flex shrink */
.flex-shrink-0 { flex-shrink: 0; }

/* ===================================================================
   Profile Avatar Utilities - Issue 7.2
   Replace inline avatar styles with reusable classes
   =================================================================== */

/* Base avatar styles */
.profile-avatar {
    object-fit: cover;
    border: 2px solid var(--primary);
    border-radius: 50%;
}

/* Avatar sizes */
.profile-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

.profile-avatar-md {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
}

.profile-avatar-lg {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    font-weight: 600;
}

.profile-avatar-xl {
    width: 120px;
    height: 120px;
    font-size: 3rem;
    font-weight: 600;
}

/* Avatar placeholder (initials) */
.profile-avatar.bg-primary {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dark mode avatar border */
[data-theme="dark"] .profile-avatar,
[data-bs-theme="dark"] .profile-avatar {
    border-color: var(--primary);
}

/* ============================================
   Required Field Indicator (Bootstrap 5 Floating Labels)
   ============================================ */

/* Required field asterisk */
.required {
    color: var(--danger);
    margin-left: 0.25rem;
    font-weight: 700;
    font-size: 1.1em;
    line-height: 1;
    vertical-align: middle;
}

/* Bootstrap Floating Labels - Required indicator positioning */
.form-floating > label .required {
    position: relative;
    top: -1px;
}

/* Dark mode - ensure asterisk is visible */
[data-theme="dark"] .required,
[data-bs-theme="dark"] .required {
    color: var(--danger); /* Lighter red for better contrast in dark mode */
}

/* Accessibility: Screen reader text */
.required[aria-label] {
    position: relative;
}



/* ============================================
   Modal Standardization - Consistent Centering
   ============================================ */

/* All modals should be vertically centered by default */
.modal-dialog {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}

@media (min-width: 576px) {
    .modal-dialog {
        min-height: calc(100% - 3.5rem);
    }
}

/* Modal header standardization */
.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-header .modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Danger modal header (for delete/destructive actions) */
.modal-header.bg-danger {
    border-bottom-color: rgb(255, 255, 255, 0.2);
}

.modal-header.bg-danger .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Warning modal header */
.modal-header.bg-warning {
    color: var(--on-warning);
    border-bottom-color: rgb(0, 0, 0, 0.1); /* design-spec: modal warning header divider tint */
}

/* Dark mode modal adjustments */
[data-theme="dark"] .modal-content,
[data-bs-theme="dark"] .modal-content {
    background-color: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-header {
    border-bottom-color: var(--border);
}

[data-theme="dark"] .modal-footer,
[data-bs-theme="dark"] .modal-footer {
    border-top-color: var(--border);
}

/* ============================================
   Icon Standardization - Bootstrap Icons
   ============================================ */

/* Icon size standards:
   - Default (no class): 1em - inline with text
   - icon-sm: 0.875rem - small/compact contexts
   - icon-md: 1.25rem - medium emphasis
   - icon-lg: 1.5rem - large/prominent
   - icon-xl: 2rem - hero/feature icons
*/

.icon-sm { font-size: 0.875rem; }
.icon-md { font-size: 1.25rem; }
.icon-lg { font-size: 1.5rem; }
.icon-xl { font-size: 2rem; }

/* Semantic icon colors - use these for consistent meaning */
.icon-success { color: var(--success); }
.icon-danger { color: var(--danger); }
.icon-warning { color: var(--warning); }
.icon-info { color: var(--primary); }
.icon-muted { color: var(--fg-3); }

/* Action icon colors (for buttons/links) */
.icon-edit { color: var(--primary); }
.icon-delete { color: var(--danger); }
.icon-view { color: var(--primary); }

/* Icons in buttons should have consistent spacing */
.btn .bi:not(:only-child) {
    margin-right: 0.375rem;
}

.btn .bi:only-child {
    margin: 0;
}

/* Icon-only buttons need consistent sizing */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    line-height: 1;
}

.btn-icon .bi {
    font-size: 1rem;
}

.btn-icon.btn-sm .bi {
    font-size: 0.875rem;
}

.btn-icon.btn-lg .bi {
    font-size: 1.25rem;
}

/* Dark mode icon adjustments */
[data-theme="dark"] .icon-muted,
[data-bs-theme="dark"] .icon-muted {
    color: var(--fg-2);
}

/* ============================================
   Badge Semantic Standards
   ============================================

   Use consistent badge colors for semantic meaning:

   STATUS BADGES:
   - bg-success: Active, Completed, Approved, Implemented
   - bg-danger: Inactive, Failed, Rejected, Critical
   - bg-warning: Pending, In Progress, Needs Review (auto text-dark)
   - bg-info: Information, Count, New
   - bg-secondary: Unknown, N/A, Default fallback
   - bg-primary: Role, Category, Type label

   PRIORITY BADGES:
   - badge-critical: Critical priority (custom gradient)
   - badge-high: High priority (custom gradient)
   - badge-medium: Medium priority
   - badge-low: Low priority
*/

/* Status badge semantic classes */
.badge-status-active { @extend .badge, .bg-success; }
.badge-status-inactive { @extend .badge, .bg-danger; }
.badge-status-pending { @extend .badge, .bg-warning; }
.badge-status-info { @extend .badge, .bg-info; }

/* Ensure all info/warning badges are readable */
.badge.bg-info {
    color: var(--on-primary);
}

/* Light background badges need dark text */
.badge.bg-light {
    color: var(--fg) !important;
}

/* Badge with icons - consistent spacing */
.badge .bi {
    font-size: 0.85em;
    vertical-align: -0.1em;
}

/* Status indicator badges (small dots) */
.badge-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.375rem;
}

