<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:helpers="clr-namespace:PerformanceMonitor.Ui;assembly=PerformanceMonitor.Ui">

    <!-- ============================================ -->
    <!-- Darling Data Light Theme                      -->
    <!-- Flat/Minimal Design                          -->
    <!-- ============================================ -->

    <!-- Brand Colors -->
    <Color x:Key="AccentColor">#2eaef1</Color>
    <Color x:Key="AccentHoverColor">#5bc4f5</Color>
    <Color x:Key="AccentPressedColor">#1a9ae0</Color>

    <!-- Background Colors -->
    <Color x:Key="BackgroundDarkColor">#F0F2F5</Color>
    <Color x:Key="AlternatingRowColor">#EDF1F7</Color>
    <Color x:Key="BackgroundColor">#F5F7FA</Color>
    <Color x:Key="BackgroundLightColor">#FFFFFF</Color>
    <Color x:Key="BackgroundLighterColor">#E8ECF0</Color>

    <!-- Text Colors (dark on light backgrounds) -->
    <Color x:Key="ForegroundColor">#1A1D23</Color>
    <Color x:Key="ForegroundDimColor">#1A1D23</Color>
    <Color x:Key="ForegroundMutedColor">#718096</Color>

    <!-- Border Colors (subtle, low-contrast) -->
    <Color x:Key="BorderColor">#DEE2E6</Color>
    <Color x:Key="BorderLightColor">#CED4DA</Color>

    <!-- Status Colors (Material Design 700 — visible against light backgrounds) -->
    <Color x:Key="SuccessColor">#2E7D32</Color>
    <Color x:Key="WarningColor">#F57F17</Color>
    <Color x:Key="ErrorColor">#C62828</Color>
    <Color x:Key="InfoColor">#2eaef1</Color>

    <!-- Spacing Scale -->
    <sys:Double x:Key="SpacingXS">2</sys:Double>
    <sys:Double x:Key="SpacingSm">4</sys:Double>
    <sys:Double x:Key="SpacingMd">8</sys:Double>
    <sys:Double x:Key="SpacingLg">12</sys:Double>
    <sys:Double x:Key="SpacingXL">16</sys:Double>

    <!-- Corner Radius -->
    <CornerRadius x:Key="CornerRadiusSm">2</CornerRadius>
    <CornerRadius x:Key="CornerRadiusMd">4</CornerRadius>
    <CornerRadius x:Key="CornerRadiusLg">6</CornerRadius>

    <!-- Brushes -->
    <SolidColorBrush x:Key="AccentBrush" Color="{StaticResource AccentColor}"/>
    <SolidColorBrush x:Key="AccentHoverBrush" Color="{StaticResource AccentHoverColor}"/>
    <SolidColorBrush x:Key="AccentPressedBrush" Color="{StaticResource AccentPressedColor}"/>

    <SolidColorBrush x:Key="BackgroundDarkBrush" Color="{StaticResource BackgroundDarkColor}"/>
    <SolidColorBrush x:Key="AlternatingRowBrush" Color="{StaticResource AlternatingRowColor}"/>
    <SolidColorBrush x:Key="BackgroundBrush" Color="{StaticResource BackgroundColor}"/>
    <SolidColorBrush x:Key="BackgroundLightBrush" Color="{StaticResource BackgroundLightColor}"/>
    <SolidColorBrush x:Key="BackgroundLighterBrush" Color="{StaticResource BackgroundLighterColor}"/>

    <SolidColorBrush x:Key="ForegroundBrush" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="ForegroundDimBrush" Color="{StaticResource ForegroundDimColor}"/>
    <SolidColorBrush x:Key="ForegroundMutedBrush" Color="{StaticResource ForegroundColor}"/>

    <SolidColorBrush x:Key="BorderBrush" Color="{StaticResource BorderColor}"/>
    <SolidColorBrush x:Key="BorderLightBrush" Color="{StaticResource BorderLightColor}"/>

    <SolidColorBrush x:Key="SuccessBrush" Color="{StaticResource SuccessColor}"/>
    <SolidColorBrush x:Key="WarningBrush" Color="{StaticResource WarningColor}"/>
    <!-- Legible warning amber for content text/borders (block-chain longest-wait, flag banner).
         Darker on light themes so it clears >=4.5:1 as TEXT on content backgrounds; any control may adopt it. -->
    <SolidColorBrush x:Key="WarningTextBrush" Color="#92400E"/>
    <!-- Apex (lead-blocker) node + legend border. Darker blue on light themes so it clears >=3:1 as a
         graphical border on the light node card (bright #4FA3FF is only ~2.6:1 on white). The LEAD BLOCKER
         badge fill keeps the bright ApexBrush constant so the apex still pops. -->
    <SolidColorBrush x:Key="ApexBorderBrush" Color="#1976D2"/>
    <!-- Deadlock victim node border + VICTIM badge fill, and the "waits for" edge/arrow. Tuned per theme
         so the victim red clears >=3:1 as a border on the light node card and the edge reads on the canvas. -->
    <SolidColorBrush x:Key="DeadlockVictimBrush" Color="#C62828"/>
    <SolidColorBrush x:Key="DeadlockEdgeBrush" Color="#5A6270"/>
    <SolidColorBrush x:Key="ErrorBrush" Color="{StaticResource ErrorColor}"/>
    <SolidColorBrush x:Key="InfoBrush" Color="{StaticResource InfoColor}"/>

    <!-- ============================================ -->
    <!-- Window Style                                 -->
    <!-- ============================================ -->
    <Style TargetType="Window">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>

    <!-- ============================================ -->
    <!-- TextBlock Style                              -->
    <!-- ============================================ -->
    <Style TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>

    <!-- ============================================ -->
    <!-- Label Style                                  -->
    <!-- ============================================ -->
    <Style TargetType="Label">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
    </Style>

    <!-- ============================================ -->
    <!-- Button Style - Flat Design                   -->
    <!-- ============================================ -->
    <Style TargetType="Button">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="#1A1D23"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="12,6"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            Padding="{TemplateBinding Padding}"
                            TextElement.Foreground="{TemplateBinding Foreground}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="{StaticResource BackgroundLighterColor}" Duration="0:0:0.12"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="{StaticResource BackgroundLightColor}" Duration="0:0:0.12"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource AccentPressedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Accent Button Style (for primary actions) -->
    <Style x:Key="AccentButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
        <Setter Property="Background" Value="{StaticResource AccentBrush}"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderThickness="0"
                            CornerRadius="3"
                            Padding="{TemplateBinding Padding}"
                            TextElement.Foreground="{TemplateBinding Foreground}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource AccentHoverBrush}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource AccentPressedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Time Range Button Style (hour picker with visible hover) -->
    <Style x:Key="TimeRangeButton" TargetType="Button">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundDimBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="10,5"/>
        <Setter Property="MinWidth" Value="60"/>
        <Setter Property="Margin" Value="2,0"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            Padding="{TemplateBinding Padding}"
                            TextElement.Foreground="{TemplateBinding Foreground}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource BackgroundLighterBrush}"/>
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                            <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource AccentPressedBrush}"/>
                            <Setter Property="Foreground" Value="White"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- No Data Message Style (for empty DataGrids) -->
    <Style x:Key="NoDataMessage" TargetType="TextBlock">
        <Setter Property="Text" Value="No data for selected time range"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Visibility" Value="Collapsed"/>
    </Style>

    <!-- Empty State Message Style (context-specific text set per usage) -->
    <Style x:Key="EmptyStateMessage" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Visibility" Value="Collapsed"/>
    </Style>

    <!-- Alert Badge Styles -->
    <Style x:Key="AlertBadge" TargetType="Border">
        <Setter Property="Background" Value="#D97706"/>
        <Setter Property="CornerRadius" Value="3"/>
        <Setter Property="Padding" Value="4,1"/>
        <Setter Property="Margin" Value="6,0,0,0"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <Style x:Key="AlertBadgeCritical" TargetType="Border">
        <Setter Property="Background" Value="#DC2626"/>
        <Setter Property="CornerRadius" Value="3"/>
        <Setter Property="Padding" Value="4,1"/>
        <Setter Property="Margin" Value="6,0,0,0"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <!-- ToggleButton Style (respects Background in all states) -->
    <Style TargetType="ToggleButton">
        <Setter Property="Background" Value="#E8ECF0"/>
        <Setter Property="Foreground" Value="#1A1D23"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="12,5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border x:Name="Border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            CornerRadius="2">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="Opacity" Value="0.85"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Border" Property="Opacity" Value="0.7"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Background" Value="#2E7D32"/>
                <Setter Property="Foreground" Value="White"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- Tab Close Button Style -->
    <Style x:Key="TabCloseButton" TargetType="Button">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Width" Value="22"/>
        <Setter Property="Height" Value="22"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Margin" Value="6,0,0,0"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="FontSize" Value="15"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="ToolTip" Value="Close tab"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            CornerRadius="3"
                            Width="{TemplateBinding Width}"
                            Height="{TemplateBinding Height}">
                        <TextBlock Text="×"
                                   FontSize="{TemplateBinding FontSize}"
                                   FontWeight="{TemplateBinding FontWeight}"
                                   Foreground="{TemplateBinding Foreground}"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Margin="0,-2,0,0"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="#C42B1C"/>
                            <Setter Property="Foreground" Value="White"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="border" Property="Background" Value="#9A2316"/>
                            <Setter Property="Foreground" Value="White"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Success Button Style (for Refresh) -->
    <Style x:Key="SuccessButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
        <Setter Property="Background" Value="{StaticResource SuccessBrush}"/>
        <Setter Property="Foreground" Value="#E4E6EB"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderThickness="0"
                            CornerRadius="3"
                            Padding="{TemplateBinding Padding}"
                            TextElement.Foreground="{TemplateBinding Foreground}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="#5DBF60"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="border" Property="Background" Value="#3D9140"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- TextBox Style                                -->
    <!-- ============================================ -->

    <!-- Named style for filter TextBoxes in DataGrid column headers -->
    <Style x:Key="FilterTextBoxStyle" TargetType="TextBox">
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="#1A1D23"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="4,2"/>
        <Setter Property="CaretBrush" Value="#1A1D23"/>
        <Setter Property="SelectionBrush" Value="{StaticResource AccentBrush}"/>
    </Style>

    <!-- Column Filter Button Style - small button with filter icon -->
    <Style x:Key="ColumnFilterButtonStyle" TargetType="Button">
        <Setter Property="Width" Value="18"/>
        <Setter Property="Height" Value="18"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Content" Value="&#xE71C;"/>
        <Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundDimBrush}"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ContentPresenter HorizontalAlignment="Center"
                                          VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- Column Filter Button Style when filter is active -->
    <Style x:Key="ColumnFilterButtonActiveStyle" TargetType="Button" BasedOn="{StaticResource ColumnFilterButtonStyle}">
        <Setter Property="Foreground" Value="#FFD700"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="#FFEC8B"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="TextBox">
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="6,4"/>
        <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="SelectionBrush" Value="{StaticResource AccentBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            TextElement.Foreground="{StaticResource ForegroundBrush}">
                        <ScrollViewer x:Name="PART_ContentHost"
                                      Background="{StaticResource BackgroundDarkBrush}"
                                      Margin="{TemplateBinding Padding}"
                                      Foreground="{StaticResource ForegroundBrush}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- PasswordBox Style                            -->
    <!-- ============================================ -->
    <Style TargetType="PasswordBox">
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="6,4"/>
        <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="SelectionBrush" Value="{StaticResource AccentBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="PasswordBox">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3">
                        <ScrollViewer x:Name="PART_ContentHost"
                                      Margin="{TemplateBinding Padding}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- ComboBox Style                               -->
    <!-- ============================================ -->
    <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="20"/>
            </Grid.ColumnDefinitions>
            <Border x:Name="Border" Grid.ColumnSpan="2"
                    Background="{StaticResource BackgroundDarkBrush}"
                    BorderBrush="{StaticResource BorderBrush}"
                    BorderThickness="1" CornerRadius="2"/>
            <Border Grid.Column="0" Margin="1"
                    Background="{StaticResource BackgroundDarkBrush}"
                    BorderThickness="0"/>
            <Path x:Name="Arrow" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"
                  Data="M 0 0 L 4 4 L 8 0 Z" Fill="{StaticResource ForegroundBrush}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="ComboBox">
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="6,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid>
                        <ToggleButton x:Name="ToggleButton"
                                      Template="{StaticResource ComboBoxToggleButton}"
                                      Focusable="False"
                                      IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                      ClickMode="Press"/>
                        <ContentPresenter x:Name="ContentSite" IsHitTestVisible="False"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          Margin="6,4,23,4" VerticalAlignment="Center" HorizontalAlignment="Left">
                            <ContentPresenter.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
                                </Style>
                            </ContentPresenter.Resources>
                        </ContentPresenter>
                        <TextBox x:Name="PART_EditableTextBox"
                                 Style="{x:Null}"
                                 HorizontalAlignment="Left" VerticalAlignment="Center"
                                 Margin="6,4,23,4" Focusable="True"
                                 Background="Transparent" Foreground="{StaticResource ForegroundBrush}"
                                 Visibility="Hidden" IsReadOnly="{TemplateBinding IsReadOnly}"/>
                        <Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}"
                               AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
                            <Grid x:Name="DropDown" SnapsToDevicePixels="True"
                                  MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                <Border x:Name="DropDownBorder"
                                        Background="{StaticResource BackgroundDarkBrush}"
                                        BorderBrush="{StaticResource BorderBrush}" BorderThickness="1"/>
                                <ScrollViewer Margin="1" SnapsToDevicePixels="True">
                                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ComboBoxItem">
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Padding" Value="6,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border x:Name="Bd" Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource AccentHoverBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- TabControl Style                             -->
    <!-- ============================================ -->
    <Style TargetType="TabControl">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="0"/>
    </Style>

    <Style TargetType="TabItem">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundDimBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="12,8"/>
        <Setter Property="Margin" Value="0,0,2,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderThickness="0"
                            CornerRadius="3,3,0,0"
                            Padding="{TemplateBinding Padding}"
                            Margin="{TemplateBinding Margin}">
                        <ContentPresenter x:Name="contentPresenter"
                                          ContentSource="Header"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource AccentBrush}"/>
                            <Setter Property="Foreground" Value="#1A1D23"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource BackgroundLighterBrush}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="IsMouseOver" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="border" Property="Background" Value="{StaticResource AccentHoverBrush}"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Sub-tab style: thin accent underline instead of filled background, so the hierarchy
         reads at a glance when a main tab's sub-tabs are shown alongside the main tab bar. -->
    <Style x:Key="SubTabItemStyle" TargetType="TabItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundDimBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="10,6"/>
        <Setter Property="Margin" Value="0,0,4,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{StaticResource AccentBrush}"
                            BorderThickness="0"
                            Padding="{TemplateBinding Padding}">
                        <ContentPresenter ContentSource="Header"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="border" Property="BorderThickness" Value="0,0,0,2"/>
                            <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource BackgroundLighterBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- DataGrid Selection Colors                    -->
    <!-- ============================================ -->
    <!-- Foreground to use on selected rows (dark text on the light accent background) -->
    <SolidColorBrush x:Key="GridSelectionForegroundBrush" Color="#1A1D23"/>

    <!-- Override WPF system selection brushes so all controls (DataGrid, ListBox, etc.)
         use the theme accent and the matching readable text color. -->
    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"                    Color="{StaticResource AccentColor}"/>
    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"                Color="#1A1D23"/>
    <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"   Color="{StaticResource AccentColor}"/>
    <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="#1A1D23"/>

    <!-- Named base style for DataGridTextColumn ElementStyles that must set an explicit
         Foreground.  BasedOn this style; keep the unselected Foreground setter in the
         derived style and let this base trigger override it during row selection. -->
    <Style x:Key="DataGridCellText" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow, AncestorLevel=1}, FallbackValue=False}" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource GridSelectionForegroundBrush}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <!-- ============================================ -->
    <!-- DataGrid Style                               -->
    <!-- ============================================ -->
    <Style TargetType="DataGrid">
        <Setter Property="helpers:DataGridClipboardBehavior.FixHeaderCopy" Value="True"/>
        <Setter Property="helpers:ScrollPanBehavior.EnableMiddleClickPanning" Value="True"/>
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="ClipToBounds" Value="True"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="RowBackground" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="AlternatingRowBackground" Value="{StaticResource AlternatingRowBrush}"/>
        <Setter Property="GridLinesVisibility" Value="Horizontal"/>
        <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="HeadersVisibility" Value="Column"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible"/>
    </Style>

    <!-- Column header resize gripper -->
    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="DataGridColumnHeader">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="0,0,1,1"/>
        <Setter Property="Padding" Value="8,6"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridColumnHeader">
                    <Grid>
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter Grid.Column="0"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="Center"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                <Path x:Name="SortArrow"
                                      Grid.Column="1"
                                      HorizontalAlignment="Center"
                                      VerticalAlignment="Center"
                                      Width="8" Height="6"
                                      Margin="4,0,2,0"
                                      Stretch="Fill"
                                      Opacity="0.7"
                                      Fill="{StaticResource ForegroundDimBrush}"
                                      RenderTransformOrigin="0.5,0.5"
                                      Visibility="Collapsed"
                                      Data="M 0,0 L 8,0 L 4,6 Z"/>
                            </Grid>
                        </Border>
                        <Thumb x:Name="PART_LeftHeaderGripper"
                               HorizontalAlignment="Left"
                               Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper"
                               HorizontalAlignment="Right"
                               Style="{StaticResource ColumnHeaderGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="SortArrow" Property="RenderTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="180"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Column header style when filter is active - subtle blue highlight -->
    <Style x:Key="FilteredColumnHeaderStyle" TargetType="DataGridColumnHeader"
           BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
        <Setter Property="Background" Value="#BBDEFB"/>
    </Style>

    <!-- Right-aligned text style for numeric DataGrid columns -->
    <Style x:Key="NumericCell" TargetType="TextBlock" BasedOn="{StaticResource DataGridCellText}">
        <Setter Property="TextAlignment" Value="Right"/>
    </Style>

    <Style TargetType="DataGridCell">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="8,6"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridCell">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">
                        <ContentPresenter VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{StaticResource AccentBrush}"/>
                <Setter Property="Foreground" Value="#1A1D23"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="DataGridRow">
        <Setter Property="Background" Value="Transparent"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{StaticResource AccentBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource GridSelectionForegroundBrush}"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource BackgroundLighterBrush}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- ============================================ -->
    <!-- ListView Style                               -->
    <!-- ============================================ -->
    <Style TargetType="ListView">
        <Setter Property="helpers:ScrollPanBehavior.EnableMiddleClickPanning" Value="True"/>
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
    </Style>

    <Style TargetType="ListViewItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Padding" Value="8,6"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border x:Name="border"
                            Background="{TemplateBinding Background}"
                            CornerRadius="3"
                            Padding="{TemplateBinding Padding}">
                        <ContentPresenter/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource BackgroundLighterBrush}"/>
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                            <Setter TargetName="border" Property="BorderThickness" Value="1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- ScrollBar Style                              -->
    <!-- ============================================ -->
    <Style TargetType="ScrollBar">
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
    </Style>

    <!-- ============================================ -->
    <!-- Border Style for Panels                      -->
    <!-- ============================================ -->
    <Style x:Key="PanelBorder" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="CornerRadius" Value="6"/>
        <Setter Property="Padding" Value="16"/>
    </Style>

    <!-- Card Style for Chart Containers -->
    <Style x:Key="ChartCard" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="CornerRadius" Value="6"/>
        <Setter Property="Margin" Value="6"/>
    </Style>

    <!-- ============================================ -->
    <!-- DatePickerTextBox Style (internal control)   -->
    <!-- ============================================ -->
    <Style TargetType="DatePickerTextBox">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DatePickerTextBox">
                    <Grid Background="{StaticResource BackgroundLightBrush}">
                        <Border x:Name="Border"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer x:Name="PART_ContentHost" Background="Transparent"
                                          HorizontalContentAlignment="Stretch"
                                          VerticalContentAlignment="Center"/>
                        </Border>
                        <!-- Watermark: hidden via Visibility=Collapsed -->
                        <ContentControl x:Name="PART_Watermark"
                                        Focusable="False"
                                        IsHitTestVisible="False"
                                        Visibility="Collapsed"
                                        Foreground="{StaticResource ForegroundMutedBrush}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- DatePicker Style                             -->
    <!-- ============================================ -->
    <Style TargetType="DatePicker">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="4,2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DatePicker">
                    <Border x:Name="OuterBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            Padding="{TemplateBinding Padding}">
                        <Grid x:Name="PART_Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <DatePickerTextBox x:Name="PART_TextBox"
                                               Grid.Column="0"
                                               Focusable="True"
                                               HorizontalContentAlignment="Stretch"
                                               VerticalContentAlignment="Center"
                                               Background="Transparent"
                                               Foreground="{StaticResource ForegroundBrush}"/>
                            <Button x:Name="PART_Button"
                                    Grid.Column="1"
                                    Focusable="False"
                                    Foreground="{StaticResource ForegroundBrush}"
                                    Background="Transparent"
                                    BorderThickness="0"
                                    Padding="4,0">
                                <Path Data="M0,0 L4,4 L8,0 Z"
                                      Fill="{StaticResource ForegroundBrush}"
                                      VerticalAlignment="Center"/>
                            </Button>
                            <Popup x:Name="PART_Popup"
                                   AllowsTransparency="True"
                                   Placement="Bottom"
                                   PlacementTarget="{Binding ElementName=OuterBorder}"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- Calendar Styles for DatePicker dropdown      -->
    <!-- ============================================ -->

    <!-- Calendar main style with full template -->
    <Style TargetType="Calendar">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Calendar">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3">
                        <CalendarItem x:Name="PART_CalendarItem"
                                      Background="{StaticResource BackgroundBrush}"
                                      BorderThickness="0"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- CalendarItem style (the container for month/year views) -->
    <Style TargetType="CalendarItem">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CalendarItem">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <!-- Header: Previous/Next buttons and Month/Year title -->
                            <Grid Grid.Row="0" Background="{StaticResource BackgroundLightBrush}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>

                                <Button x:Name="PART_PreviousButton" Grid.Column="0"
                                        Content="&#x25C0;" FontWeight="Bold"
                                        Background="Transparent" Foreground="{StaticResource ForegroundBrush}"
                                        BorderThickness="0" Padding="10,5"
                                        Cursor="Hand"/>

                                <Button x:Name="PART_HeaderButton" Grid.Column="1"
                                        HorizontalAlignment="Center"
                                        Background="Transparent" Foreground="{StaticResource ForegroundBrush}"
                                        BorderThickness="0" FontWeight="SemiBold" FontSize="14"
                                        Padding="5" Cursor="Hand"/>

                                <Button x:Name="PART_NextButton" Grid.Column="2"
                                        Content="&#x25B6;" FontWeight="Bold"
                                        Background="Transparent" Foreground="{StaticResource ForegroundBrush}"
                                        BorderThickness="0" Padding="10,5"
                                        Cursor="Hand"/>
                            </Grid>

                            <!-- Day grid or Month/Year grid -->
                            <Grid Grid.Row="1" Background="{StaticResource BackgroundBrush}">
                                <Grid x:Name="PART_MonthView" Visibility="Visible">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                </Grid>
                                <Grid x:Name="PART_YearView" Visibility="Hidden">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                </Grid>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- CalendarDayButton style (individual day cells) -->
    <Style TargetType="CalendarDayButton">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="MinWidth" Value="32"/>
        <Setter Property="MinHeight" Value="32"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CalendarDayButton">
                    <Grid>
                        <Border x:Name="Background" Background="Transparent" CornerRadius="3"/>
                        <ContentPresenter x:Name="Content"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                        <Trigger Property="IsToday" Value="True">
                            <Setter TargetName="Background" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                            <Setter TargetName="Background" Property="BorderThickness" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsInactive" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsBlackedOut" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
                            <Setter Property="Opacity" Value="0.4"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- CalendarButton style (month/year selection cells) -->
    <Style TargetType="CalendarButton">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="MinWidth" Value="50"/>
        <Setter Property="MinHeight" Value="32"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CalendarButton">
                    <Grid>
                        <Border x:Name="Background" Background="Transparent" CornerRadius="3"/>
                        <ContentPresenter x:Name="Content"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
                        </Trigger>
                        <Trigger Property="HasSelectedDays" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                        <Trigger Property="IsInactive" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- CheckBox Style                               -->
    <!-- ============================================ -->
    <Style TargetType="CheckBox">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <BulletDecorator Background="Transparent" VerticalAlignment="Center">
                        <BulletDecorator.Bullet>
                            <Border x:Name="Border" Width="16" Height="16"
                                    Background="{StaticResource BackgroundDarkBrush}"
                                    BorderBrush="{StaticResource BorderBrush}"
                                    BorderThickness="1" CornerRadius="2">
                                <Path x:Name="CheckMark" Width="10" Height="10" Stretch="Fill"
                                      Stroke="{StaticResource AccentBrush}" StrokeThickness="2"
                                      Data="M 0,5 L 4,9 L 10,0" Visibility="Collapsed"
                                      HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Border>
                        </BulletDecorator.Bullet>
                        <ContentPresenter Margin="6,0,0,0"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Left"
                                          RecognizesAccessKey="True"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource BackgroundDarkBrush}"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource ForegroundMutedBrush}"/>
                            <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- ContextMenu Style                            -->
    <!-- ============================================ -->
    <Style TargetType="ContextMenu">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderLightBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContextMenu">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            CornerRadius="4">
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="MenuItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="MenuItem">
                    <Border x:Name="Border" Background="{TemplateBinding Background}" BorderThickness="0">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="26" SharedSizeGroup="MenuItemIconColumnGroup"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="17"/>
                            </Grid.ColumnDefinitions>
                            <!-- Icon column -->
                            <Border x:Name="IconColumn" Grid.Column="0" Background="Transparent"/>
                            <ContentPresenter x:Name="Icon" Grid.Column="0" Margin="4,0,6,0" VerticalAlignment="Center" ContentSource="Icon"/>
                            <ContentPresenter Grid.Column="1" Margin="8,4" VerticalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource BackgroundLighterBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource ForegroundMutedBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ============================================ -->
    <!-- Separator Style                              -->
    <!-- ============================================ -->
    <Style TargetType="Separator">
        <Setter Property="Background" Value="{StaticResource BorderBrush}"/>
        <Setter Property="Margin" Value="0,4"/>
        <Setter Property="Height" Value="1"/>
    </Style>

    <!-- ============================================ -->
    <!-- ToolTip Style                                -->
    <!-- ============================================ -->
    <Style x:Key="DarkToolTip" TargetType="ToolTip">
        <Setter Property="Background" Value="{StaticResource BackgroundLightBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderLightBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="10,8"/>
        <Setter Property="MaxWidth" Value="600"/>
    </Style>

    <!-- Apply DarkToolTip as the default for all tooltips -->
    <Style TargetType="ToolTip" BasedOn="{StaticResource DarkToolTip}"/>

    <!-- Time Range Slicer -->
    <SolidColorBrush x:Key="SlicerBackgroundBrush" Color="#F0F2F5"/>
    <SolidColorBrush x:Key="SlicerChartLineBrush" Color="#2196F3"/>
    <SolidColorBrush x:Key="SlicerChartFillBrush" Color="#332196F3"/>
    <SolidColorBrush x:Key="SlicerOverlayBrush" Color="#55FFFFFF"/>
    <SolidColorBrush x:Key="SlicerSelectedBrush" Color="#11000000"/>
    <SolidColorBrush x:Key="SlicerHandleBrush" Color="#4A5568"/>
    <SolidColorBrush x:Key="SlicerHandleHoverBrush" Color="#2196F3"/>
    <SolidColorBrush x:Key="SlicerBorderBrush" Color="#CBD5E0"/>
    <SolidColorBrush x:Key="SlicerLabelBrush" Color="#718096"/>
    <SolidColorBrush x:Key="SlicerToggleBrush" Color="#4A5568"/>

    <!-- ============================================ -->
    <!-- Plan Viewer Resources                        -->
    <!-- ============================================ -->
    <SolidColorBrush x:Key="PlanTooltipBgBrush" Color="#FFFFFF"/>
    <SolidColorBrush x:Key="PlanTooltipBorderBrush" Color="{StaticResource BorderColor}"/>
    <SolidColorBrush x:Key="PlanPanelTextBrush" Color="{StaticResource ForegroundColor}"/>
    <SolidColorBrush x:Key="PlanPanelMutedBrush" Color="{StaticResource ForegroundMutedColor}"/>
    <SolidColorBrush x:Key="PlanSectionHeaderBrush" Color="{StaticResource AccentPressedColor}"/>
    <SolidColorBrush x:Key="PlanPropSeparatorBrush" Color="{StaticResource BorderColor}"/>
    <SolidColorBrush x:Key="PlanMissingIndexBgBrush" Color="#FFF8E1"/>
    <SolidColorBrush x:Key="PlanMissingIndexBorderBrush" Color="#FFD54F"/>
    <SolidColorBrush x:Key="PlanMissingIndexHeaderBrush" Color="#E65100"/>
    <SolidColorBrush x:Key="PlanWaitStatsBgBrush" Color="#E3F2FD"/>
    <SolidColorBrush x:Key="PlanWaitStatsHeaderBrush" Color="#1565C0"/>

</ResourceDictionary>
