/* ===================================
   IMS Design System
   =================================== */

/* CSS Custom Properties */
:root {
    /* Colors - Dark Theme (default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-glass: rgba(26, 26, 36, 0.8);

    /* Liquid Glass */
    --glass-blur: 24px;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-bg-hover: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.05);

    --text-primary: #e9edf2;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);

    /* Status Colors (User-facing: 3 states) */
    --status-triggered: #818cf8;
    --status-triggered-glow: rgba(129, 140, 248, 0.2);
    --status-acknowledged: #a1a5ae;
    --status-acknowledged-glow: rgba(161, 165, 174, 0.2);
    --status-resolved: #8b9299;
    --status-resolved-glow: rgba(139, 146, 153, 0.18);

    /* Action Colors */
    --action-danger: #ef4444;
    --action-success: #22c55e;

    /* Severity Colors (Dark Theme Defaults) */
    --severity-critical: #e07a72;
    --severity-warning: #d4b25a;
    --severity-info: #9ca3af;
    --severity-critical-border: #c94a42;
    --severity-warning-border: #b38b12;
    --severity-info-border: #6b7280;
    --severity-critical-chip: rgba(224, 122, 114, 0.65);
    --severity-warning-chip: rgba(212, 178, 90, 0.55);
    --severity-info-chip: rgba(156, 163, 175, 0.45);
    --severity-critical-badge: #e07a72;
    --severity-warning-badge: #d4b25a;
    --severity-info-badge: #9ca3af;

    /* Accent */
    --accent-primary: #6366f1;
    --accent-hover: #818cf8;

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

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Layout */
    --sidebar-width: 240px;
    --header-height: 48px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #e8eaed;
    --bg-secondary: #f0f2f5;
    --bg-tertiary: #d8dce3;
    --bg-glass: rgba(255, 255, 255, 0.6);

    --glass-bg: rgba(0, 0, 0, 0.04);
    --glass-bg-hover: rgba(0, 0, 0, 0.07);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-border-hover: rgba(0, 0, 0, 0.15);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);

    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #7a7a8e;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(120, 100, 160, 0.4);

    /* Softer accent for light theme - more glass-like */
    --accent-primary: #8b7db8;
    --accent-hover: #a091c8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* State colors for light theme */
    --status-triggered: #4f5fd3;
    --status-triggered-glow: rgba(79, 95, 211, 0.25);
    --status-acknowledged: #5a6170;
    --status-acknowledged-glow: rgba(90, 97, 112, 0.2);
    --status-resolved: #6b7280;
    --status-resolved-glow: rgba(107, 114, 128, 0.2);

    --action-danger: #dc2626;
    --action-success: #16a34a;

    --severity-critical: #c9453c;
    --severity-warning: #b5850f;
    --severity-info: #6b7280;
    --severity-critical-border: #c9453c;
    --severity-warning-border: #b5850f;
    --severity-info-border: #9ca3af;
    --severity-critical-chip: rgba(201, 69, 60, 0.75);
    --severity-warning-chip: rgba(181, 133, 15, 0.65);
    --severity-info-chip: rgba(107, 114, 128, 0.5);
    --severity-critical-badge: #c9453c;
    --severity-warning-badge: #b5850f;
    --severity-info-badge: #6b7280;
}

/* Theme Toggle Icons */
.theme-icon-light {
    display: none;
}

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

[data-theme="light"] .theme-icon-light {
    display: block;
}

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

/* Light theme background blobs - more vibrant */
[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse 1000px 700px at 20% 30%, rgba(99, 102, 241, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse 900px 600px at 80% 20%, rgba(236, 72, 153, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse 800px 550px at 70% 70%, rgba(34, 197, 94, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse 850px 600px at 30% 80%, rgba(234, 179, 8, 0.15) 0%, transparent 50%);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    position: relative;
}

/* Liquid Glass Background - Color blobs */
/* NOTE: Animation disabled for performance. Static gradient is GPU-friendly. */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 1000px 700px at 20% 30%, rgba(99, 102, 241, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse 900px 600px at 80% 20%, rgba(236, 72, 153, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 800px 550px at 70% 70%, rgba(34, 197, 94, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse 850px 600px at 30% 80%, rgba(234, 179, 8, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    will-change: transform;
    /* Hint to browser to promote to layer */
}

/* Uncomment to enable subtle animation (uses more GPU):
@keyframes blobMove {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-20px, 10px) scale(1.02); }
    100% { transform: translate(10px, -15px) scale(0.98); }
}
*/

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none !important;
    }

    .alert-group-card,
    .user-card,
    .btn,
    .modal {
        transition: none !important;
    }
}

/* ===================================
   Layout
   =================================== */

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Global Header - Full width across entire page */
.global-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 200;
    backdrop-filter: blur(12px);
}

/* Logo area - fixed width matching sidebar */
.global-header-logo {
    width: var(--sidebar-width);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 var(--space-lg);
    flex-shrink: 0;
    height: 100%;
}

/* Content header area - after logo, takes remaining space */
.global-header-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-xl);
}

.global-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.global-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: var(--bg-tertiary);
}

/* Sidebar Overlay (mobile only) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-base);
}

@media (max-width: 768px) {
    .sidebar-overlay.visible {
        display: block;
        opacity: 1;
    }
}

/* App Body - Sidebar + Content row */
.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
    /* for proper scrolling */
}

/* Sidebar - Now relative within app-body */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 24px;
    height: 24px;
    color: var(--status-triggered);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.icon {
    width: 18px;
    height: 18px;
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    margin-bottom: var(--space-xs);
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-primary);
    color: var(--text-primary);
}

.nav-item.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.nav-item.disabled:hover {
    background: transparent;
    color: var(--text-secondary);
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.refresh-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.refresh-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-resolved);
    animation: pulse 2s infinite;
    will-change: opacity;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: var(--space-xl);
    min-height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

/* Page Header (inside main-content) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Mode Switcher in Global Header */
.header-mode-switcher {
    flex-shrink: 0;
}

.header-mode-switcher .mode-switcher {
    display: flex;
    gap: 0;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.header-mode-switcher .mode-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.header-mode-switcher .mode-btn .mode-icon {
    width: 14px;
    height: 14px;
    opacity: 0.8;
}

.header-mode-switcher .mode-btn:hover:not(.disabled):not(:disabled):not(.active) {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.header-mode-switcher .mode-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.4);
}

.header-mode-switcher .mode-btn.active .mode-icon {
    opacity: 1;
}

.header-mode-switcher .mode-btn.disabled,
.header-mode-switcher .mode-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* ===================================
   Buttons
   =================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:hover:not(:disabled) {
    background: var(--bg-glass);
    border-color: var(--border-focus);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8125rem;
}

.btn-secondary {
    background: transparent;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-sm.btn-icon {
    width: 28px;
    height: 28px;
}

.btn-sm.btn-icon svg {
    width: 14px;
    height: 14px;
}

.btn-danger {
    background: var(--action-danger);
    border-color: var(--action-danger);
}

.btn-success {
    background: var(--action-success);
    border-color: var(--action-success);
}

/* ===================================
   Filters
   =================================== */

.filters-bar {
    margin-bottom: var(--space-lg);
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.filters-right {
    margin-left: auto;
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
}

.filter-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    line-height: 1;
}

.state-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.state-tab {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: calc(var(--radius-lg) - 6px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.state-tab:hover {
    color: var(--text-primary);
}

.state-tab.active {
    background: var(--glass-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.state-tab:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.severity-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.severity-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 6px 12px;
    border-radius: calc(var(--radius-lg) - 6px);
    border: 0.75px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 32px;
}

.severity-chip.active {
    background: var(--glass-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.severity-chip[data-severity="critical"].active {
    border-color: var(--severity-critical-badge);
    color: var(--severity-critical-badge);
}

.severity-chip[data-severity="warning"].active {
    border-color: var(--severity-warning-badge);
    color: var(--severity-warning-badge);
}

.severity-chip[data-severity="info"].active {
    border-color: var(--severity-info-badge);
    color: var(--severity-info-badge);
}

.severity-chip:not(.active) {
    opacity: 0.6;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-tab:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.status-triggered {
    background: var(--status-triggered);
}

.status-dot.status-acknowledged {
    background: var(--status-acknowledged);
}

.status-dot.status-resolved {
    background: var(--status-resolved);
}

/* ===================================
   Alert Groups Grid
   =================================== */

.alert-groups-container {
    position: relative;
    min-height: 200px;
}

.alert-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-md);
}

/* Alert Group Card */
.alert-group-card {
    background: var(--glass-bg);
    /* backdrop-filter disabled for GPU performance */
    /* backdrop-filter: blur(var(--glass-blur)) saturate(180%); */
    /* -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%); */
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: var(--glass-shadow), var(--glass-inset);
}

.alert-group-card.is-highlighted {
    box-shadow: 0 0 0 2px rgba(124, 140, 248, 0.6), 0 0 16px rgba(124, 140, 248, 0.25), var(--glass-shadow), var(--glass-inset);
}

[data-theme="light"] .alert-group-card.is-highlighted {
    box-shadow: 0 0 0 2px rgba(91, 111, 214, 0.55), 0 0 14px rgba(91, 111, 214, 0.2), var(--glass-shadow), var(--glass-inset);
}

.alert-group-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.alert-group-card.severity-critical::before {
    background: var(--severity-critical);
}

.alert-group-card.severity-warning::before {
    background: var(--severity-warning);
}

.alert-group-card.severity-info::before {
    background: var(--severity-info);
}

.alert-group-card.severity-critical {
    border-color: var(--severity-critical-border);
    border-width: 1.5px;
}

.alert-group-card.severity-warning {
    border-color: var(--severity-warning-border);
    border-width: 1px;
}

.alert-group-card.severity-info {
    border-color: var(--severity-info-border);
    border-width: 1px;
}

.alert-group-card:hover {
    /* Simplified hover - no transform for GPU performance */
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
}

.alert-group-card.severity-critical:hover {
    border-color: var(--severity-critical);
}

.alert-group-card.severity-warning:hover {
    border-color: var(--severity-warning);
}

.alert-group-card.severity-info:hover {
    border-color: var(--severity-info);
}

.alert-group-card-header {
    margin-bottom: var(--space-sm);
}

.alert-group-title {
    font-size: 1rem;
    font-weight: 600;
    word-break: break-word;
    line-height: 1.4;
}

.alert-group-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
    justify-content: flex-end;
}

.alert-group-status-badge,
.alert-group-severity-badge {
    display: inline-flex;
    gap: var(--space-xs);
}

.alert-group-status-badge .badge-status {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.alert-group-status-badge .badge-status.status-triggered {
    color: var(--status-triggered);
    opacity: 0.85;
}

.alert-group-status-badge .badge-status.status-acknowledged {
    color: var(--status-acknowledged);
    opacity: 0.8;
}

.alert-group-status-badge .badge-status.status-resolved {
    color: var(--status-resolved);
    opacity: 0.75;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-status {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-transform: none;
    font-weight: 500;
    letter-spacing: 0;
    font-size: 0.72rem;
}

.badge-status.status-triggered {
    border-color: var(--status-triggered);
    color: var(--status-triggered);
}

.badge-status.status-acknowledged {
    border-color: var(--status-acknowledged);
    color: var(--status-acknowledged);
}

.badge-status.status-resolved {
    border-color: var(--status-resolved);
    color: var(--status-resolved);
}

.badge-status.status-firing {
    border-color: var(--status-triggered);
    color: var(--status-triggered);
}

.alert-status-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-primary);
    text-transform: none;
}

.alert-status-tag.status-firing {
    border-color: var(--action-danger);
    color: var(--action-danger);
}

.alert-status-tag.status-resolved {
    border-color: var(--action-success);
    color: var(--action-success);
}

.badge-severity {
    border: 1px solid;
    background: transparent;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 1px 6px;
    letter-spacing: 0.02em;
}

.badge-severity.severity-critical {
    border-color: var(--severity-critical-badge);
    color: var(--severity-critical-badge);
}

.badge-severity.severity-warning {
    border-color: var(--severity-warning-badge);
    color: var(--severity-warning-badge);
}

.badge-severity.severity-info {
    border-color: var(--severity-info-badge);
    color: var(--severity-info-badge);
}

.alert-group-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm) var(--space-lg);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.alert-group-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    min-width: 0;
    /* Allow text truncation */
}

.alert-group-meta-value.meta-truncate {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}

.alert-group-meta-value.meta-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.alert-group-meta-value.meta-stack .meta-primary {
    color: var(--text-primary);
}

.alert-group-meta-value.meta-stack .meta-secondary {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alert-group-meta-label {
    color: var(--text-muted);
}

.alert-group-alerts-count {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: var(--space-sm);
}

.alerts-count-main {
    color: var(--text-primary);
}

/* ===================================
   View Toggle
   =================================== */

.view-toggle-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: flex-start;
}

.view-toggle-buttons {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.view-toggle-buttons .view-btn {
    width: auto;
    height: auto;
    padding: 6px 12px;
    border-radius: calc(var(--radius-lg) - 6px);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.view-toggle-buttons .view-btn:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.view-toggle-buttons .view-btn.active {
    background: var(--glass-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* ===================================
   List View Header
   =================================== */

.list-header {
    display: none;
    /* Hidden by default (grid view) */
    grid-template-columns: 1fr 100px 80px 100px 120px 120px 90px 90px 140px;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    padding-left: calc(var(--space-lg) + 4px);
    /* Account for left border */
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.list-header-col:nth-child(9) {
    text-align: right;
}

/* Show header when list view is active */
.alert-groups-grid.view-list~.list-header,
.alert-groups-container:has(.alert-groups-grid.view-list) .list-header {
    display: grid;
}

/* ===================================
   List View Mode
   =================================== */

.alert-groups-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.alert-groups-grid.view-list .alert-group-card {
    display: grid;
    grid-template-columns: 1fr 100px 80px 100px 120px 120px 90px 90px 140px;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
}

.list-header-col[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 18px;
    /* space for arrow */
}

.list-header-col[data-sort]:hover {
    color: var(--text-primary);
}

.list-header-col[data-sort]::after {
    content: '';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.3;
}

.list-header-col[data-sort].asc::after {
    border-bottom: 5px solid currentColor;
    opacity: 1;
}

.list-header-col[data-sort].desc::after {
    border-top: 5px solid currentColor;
    opacity: 1;
}

.alert-groups-grid.view-list .alert-group-card::before {
    height: 100%;
    width: 4px;
    position: absolute;
    left: 0;
    top: 0;
}

.alert-groups-grid.view-list .alert-group-card-header {
    display: contents;
}

.alert-groups-grid.view-list .alert-group-title {
    margin-right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alert-groups-grid.view-list .alert-group-badges {
    display: contents;
}

.alert-groups-grid.view-list .alert-group-status-badge,
.alert-groups-grid.view-list .alert-group-severity-badge {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-start;
    margin-bottom: 0;
}

.alert-groups-grid.view-list .alert-group-meta {
    display: contents;
}

.alert-groups-grid.view-list .alert-group-meta-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alert-groups-grid.view-list .alert-group-meta-label {
    display: none;
}

.alerts-duration {
    color: var(--text-muted);
    font-size: 0.9em;
}

.alert-groups-grid.view-list .alert-group-alerts-count {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

/* List view mobile: horizontal scroll wrapper */
@media (max-width: 768px) {
    .alert-groups-grid.view-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .alert-groups-grid.view-list .alert-group-card {
        min-width: 800px;
    }
}

/* ===================================
   Loading & Empty States
   =================================== */

.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-md);
}

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

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

/* ===================================
   Pagination
   =================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===================================
   Modal
   =================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    /* backdrop-filter: blur(4px); - disabled for GPU performance */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: all var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

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

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.modal-footer:empty {
    display: none;
}

.modal-footer.split {
    justify-content: space-between;
}

.modal-footer-left,
.modal-footer-right {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

/* Modal Content */
.detail-section {
    margin-bottom: var(--space-lg);
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-hero {
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.detail-status-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.875rem;
}

.detail-status-line .status-severity {
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.detail-status-line .status-severity.severity-critical {
    color: var(--severity-critical);
}

.detail-status-line .status-severity.severity-warning {
    color: var(--severity-warning);
}

.detail-status-line .status-severity.severity-info {
    color: var(--severity-info-badge);
}

.detail-status-line .status-state {
    font-weight: 500;
    color: var(--text-secondary);
}

.detail-status-line .status-state.state-triggered {
    color: var(--status-triggered);
}

.detail-status-line .status-state.state-acknowledged {
    color: var(--status-acknowledged);
}

.detail-status-line .status-state.state-resolved {
    color: var(--status-resolved);
}

.detail-status-line .status-time,
.detail-status-line .status-sep {
    color: var(--text-muted);
}

.detail-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.detail-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    font-weight: 500;
}

.detail-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: var(--space-sm);
}

.detail-technical>summary.detail-section-title {
    cursor: pointer;
    list-style: none;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.detail-technical>summary.detail-section-title::-webkit-details-marker {
    display: none;
}

.detail-technical>summary.detail-section-title::after {
    content: '>';
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.detail-technical>summary.detail-section-title:hover {
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.detail-technical>summary.detail-section-title:hover::after {
    color: var(--text-primary);
}

.detail-summary-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.detail-technical[open]>summary.detail-section-title {
    margin-bottom: var(--space-sm);
}

.detail-technical[open]>summary.detail-section-title::after {
    transform: rotate(90deg);
}


.detail-subsection {
    margin-top: var(--space-md);
}

.detail-subtitle {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.detail-item {
    background: var(--bg-tertiary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.detail-value {
    font-size: 0.9375rem;
    word-break: break-word;
}

/* Alerts List */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.alert-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border-left: 3px solid var(--status-new);
}

.alert-item.status-resolved {
    border-left-color: var(--status-resolved);
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.alert-name {
    font-weight: 600;
}

.alert-labels {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.alert-labels-inline {
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.alert-labels-prefix {
    color: var(--text-muted);
}

.alert-label-nowrap {
    white-space: nowrap;
}

.alert-labels-toggle {
    float: right;
    margin-left: 8px;
    padding: 1px 8px;
    font-size: 0.7rem;
    color: var(--primary);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    vertical-align: middle;
}

.label-tag {
    display: inline-flex;
    padding: 2px 6px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-primary);
}

.alert-annotation {
    margin-top: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ===================================
   Toast Notifications
   =================================== */

.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn var(--transition-base) ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 3px solid var(--status-resolved);
}

.toast.error {
    border-left: 3px solid var(--status-new);
}

.toast.info {
    border-left: 3px solid var(--severity-info);
}

/* ===================================
   Responsive
   =================================== */

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        height: calc(100vh - var(--header-height));
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

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

    .global-header-logo {
        width: auto;
        min-width: 0;
    }

    .global-header-content {
        padding: 0 var(--space-md);
    }

    .main-content {
        margin-left: 0;
        padding: var(--space-md);
        width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    .app-body {
        min-width: 0;
        overflow-x: hidden;
    }

    .page-header {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .page-header h1 {
        width: 100%;
        font-size: 1.25rem;
    }

    .alert-groups-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    html,
    body {
        overflow-x: hidden;
    }

    .app {
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* Extra small screens */
@media (max-width: 600px) {
    .global-header {
        padding: 0 var(--space-sm);
    }

    .global-header-logo {
        padding: 0 var(--space-sm);
    }

    .global-header-content {
        padding: 0 var(--space-sm);
    }

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

    .filters-row {
        gap: var(--space-sm);
    }

    .filters-right {
        margin-left: 0;
        width: 100%;
        flex-wrap: wrap;
    }

    .state-tabs,
    .severity-chips {
        width: 100%;
        justify-content: center;
    }

    .state-tab,
    .severity-chip {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.8rem;
    }

    .btn-text {
        display: none;
    }

    .page-header h1,
    .page-title {
        font-size: 1.1rem;
    }

    .page-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Force all containers to respect viewport */
    * {
        max-width: 100%;
    }
}

/* ===================================
   Teams Navigation
   =================================== */

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-md) 0;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
}

/* Nav Section Header - with action button */
.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
}

.nav-section-header .nav-section-title {
    padding: 0;
    margin-bottom: 0;
}

/* Subtle button - for sidebar actions */
.btn-subtle {
    opacity: 0.4;
    transition: opacity var(--transition-fast), background var(--transition-fast);
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    padding: 0;
}

.btn-subtle:hover {
    opacity: 1;
    background: var(--bg-tertiary);
}

.icon-small {
    width: 14px;
    height: 14px;
}

/* Small modal */
.modal.modal-sm {
    max-width: 400px;
}

/* Large modal */
.modal.modal-lg {
    max-width: 900px;
}

/* Form hints */
.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Optional label */
.optional {
    font-weight: 400;
    color: var(--text-muted);
}

#integration-config-fields .form-group {
    margin-bottom: var(--space-md);
}

/* Clickable section link */
.nav-section-link {
    text-decoration: none;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.nav-section-link:hover .nav-section-title {
    color: var(--text-primary);
}

.nav-team .nav-icon {
    font-size: 0.875rem;
}

/* ===================================
   Teams List (Teams View)
   =================================== */

.teams-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    width: 100%;
}

.teams-list-header {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) 120px 160px;
    gap: var(--space-md);
    padding: 0 var(--space-md);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.teams-list-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.team-row {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) 120px 160px;
    gap: var(--space-md);
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-xs) var(--space-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.team-row:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-sm);
}

.team-cell {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 0;
}

.team-cell-primary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    min-width: 0;
}

.team-primary-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.team-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.team-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.team-row .team-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.75rem;
}

.team-slack {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.team-slack-empty {
    color: var(--text-muted);
}

.team-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.team-oncall-badge.configured {
    border-color: var(--status-resolved);
    color: var(--status-resolved);
}

.team-oncall-badge.unconfigured {
    border-color: var(--severity-warning);
    color: var(--severity-warning);
}

/* Teams Section Header */
.teams-section {
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-title .section-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.team-stats {
    margin-top: var(--space-md);
    display: flex;
    gap: var(--space-lg);
}

/* ===================================
   Timeline Component
   =================================== */

.timeline-section {
    margin-top: var(--space-lg);
}

.timeline-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: var(--space-sm);
}

.timeline-container::-webkit-scrollbar {
    width: 6px;
}

.timeline-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.timeline-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    font-style: italic;
}

.timeline {
    position: relative;
    padding-left: var(--space-xl);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-event {
    position: relative;
    display: flex;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-sm);
}

.timeline-event:last-child {
    padding-bottom: 0;
    margin-bottom: 0;
}

.timeline-icon {
    position: absolute;
    left: calc(-1 * var(--space-xl) + 2px);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-size: 0.875rem;
    z-index: 1;
    color: #fff;
}

.timeline-icon i,
.timeline-icon svg {
    width: 14px;
    height: 14px;
}

.timeline-content {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.timeline-message {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.timeline-actor {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.timeline-notification-details {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8rem;
    color: var(--primary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-top: var(--space-xs);
}

.timeline-notification-details svg {
    width: 14px;
    height: 14px;
}

.timeline-event.is-key .timeline-content {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.timeline-event.is-key .timeline-message {
    font-weight: 600;
}

.timeline-event.is-minor .timeline-content {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.timeline-event.is-minor .timeline-time {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.timeline-event.is-minor .timeline-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Timeline Event Type Variations */
.timeline-event.type-created .timeline-icon {
    background: var(--accent-primary);
}

.timeline-event.type-alert_added .timeline-icon {
    background: var(--status-triggered);
}

.timeline-event.type-alert_resolved .timeline-icon {
    background: var(--status-resolved);
}

.timeline-event.type-acknowledged .timeline-icon {
    background: var(--status-acknowledged);
}

.timeline-event.type-resolved .timeline-icon {
    background: var(--status-resolved);
}

.timeline-event.type-notification_sent .timeline-icon {
    background: var(--accent-primary);
}

.timeline-event.type-notification_failed .timeline-icon {
    background: var(--severity-critical);
}

.timeline-event.type-note .timeline-icon {
    background: var(--severity-info);
}

.loading-spinner {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-muted);
}

/* ===================================
   On-Call Badge
   =================================== */

.on-call-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
}

.on-call-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.on-call-icon {
    width: 16px;
    height: 16px;
    color: var(--status-resolved);
}

.on-call-label {
    color: var(--text-muted);
}

.on-call-name {
    font-weight: 600;
    color: var(--text-primary);
}

.manage-team-link {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: color var(--transition-fast);
}

.manage-team-link:hover {
    color: var(--accent-hover);
}

.manage-team-link svg {
    width: 14px;
    height: 14px;
}

/* ===================================
   Users Section
   =================================== */

.users-section {
    padding: 0;
}

.users-section .section-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.users-section .section-title {
    margin: 0;
}

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

.users-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

/* ===================================
   User List
   =================================== */

.users-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    width: 100%;
}

.users-list-header {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) 120px 120px 160px;
    gap: var(--space-md);
    padding: 0 var(--space-md);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.users-list-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.user-row {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) 120px 120px 160px;
    gap: var(--space-md);
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-xs) var(--space-md);
    transition: all var(--transition-base);
}

.user-row:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-sm);
}

.user-cell {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 0;
}

.user-cell-primary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    min-width: 0;
}

.user-primary-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}


.user-row .user-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.user-row .user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    word-break: break-word;
}

.user-row .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.user-row .user-avatar span {
    line-height: 1;
}

.user-auth-badge.auth-oidc {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.user-auth-badge.auth-local {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

.user-slack-badge.status-linked {
    border-color: var(--status-resolved);
    color: var(--status-resolved);
}

.user-slack-badge.status-unlinked {
    border-color: var(--severity-warning);
    color: var(--severity-warning);
}

.readonly-field {
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.user-form-details {
    margin-top: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    opacity: 0.8;
}

.user-form-details[open] {
    opacity: 1;
}

.user-form-details summary {
    cursor: pointer;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.user-form-details-body {
    margin-top: var(--space-sm);
}

/* ===================================
   User Card
   =================================== */

.user-card {
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
    /* backdrop-filter: blur(var(--glass-blur)); - disabled for GPU performance */
    word-break: break-word;
    overflow-wrap: break-word;
}

.user-card:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-md);
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

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

.user-name {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 var(--space-xs) 0;
    color: var(--text-primary);
}

.user-email {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    word-break: break-word;
}

.user-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.user-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.user-meta-item svg {
    width: 14px;
    height: 14px;
}

.user-slack {
    color: var(--status-resolved);
}

.user-card-actions {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.user-card-actions .btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8125rem;
}

.user-card-actions .btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ===================================
   Team Management Modal
   =================================== */

.team-modal-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.team-modal-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

/* Routing Form in Team Modal */
.routing-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.routing-form .form-group {
    margin-bottom: 0;
}

.routing-form .form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.severity-routes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

@media (max-width: 600px) {
    .severity-routes-grid {
        grid-template-columns: 1fr;
    }
}

.severity-routes-grid .form-group label {
    display: block;
    margin-bottom: 6px;
}

.team-modal-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 var(--space-md) 0;
}

.team-modal-section-title svg {
    width: 16px;
    height: 16px;
}

.team-members-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.team-member-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.team-member-info {
    flex: 1;
    min-width: 0;
}

.team-member-name {
    font-weight: 600;
    display: block;
}

.team-member-email {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.team-member-role {
    flex-shrink: 0;
}

.role-select {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
}

.role-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.add-member-form {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.form-select {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.empty-hint {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

.empty-hint svg {
    width: 16px;
    height: 16px;
}

/* ===================================
   User Form Modal
   =================================== */

.user-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.user-form-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.user-form-section-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.user-form-section-compact {
    padding-bottom: 0;
    border-bottom: none;
}

.user-form-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.user-form-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.user-form-section-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.user-form-grid {
    display: grid;
    gap: var(--space-sm);
}

.user-form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}


.user-integration-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text-secondary);
}

.user-integration-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.user-integration-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-security-card {
    border: 1px solid rgba(229, 184, 71, 0.35);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    background: rgba(229, 184, 71, 0.08);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.user-security-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    color: var(--severity-warning);
}

.user-security-header svg {
    width: 16px;
    height: 16px;
}

.user-security-note {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.user-security-action {
    align-self: flex-start;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Custom Tooltip (appears instantly on hover) */
.tooltip-icon {
    position: relative;
    display: inline-flex;
    cursor: help;
}

.tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 1000;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    max-width: 280px;
    white-space: normal;
    text-align: left;
    line-height: 1.4;
}

.tooltip-icon:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Inside modals: show tooltip below the icon, left-aligned, to avoid overflow clipping */
.modal-body .tooltip-icon::after {
    bottom: auto;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    transform: none;
}

.form-group input,
.form-group textarea {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color var(--transition-fast);
    width: 100%;
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input[readonly] {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* ===================================
   Responsive - Users
   =================================== */

@media (max-width: 768px) {
    .users-grid {
        grid-template-columns: 1fr;
    }

    .users-list-header {
        display: none;
    }

    .user-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .user-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .user-cell[data-label]::before {
        content: attr(data-label);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        margin-right: var(--space-md);
    }

    .user-cell-primary {
        justify-content: flex-start;
    }

    .teams-list-header {
        display: none;
    }

    .team-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .team-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .team-cell[data-label]::before {
        content: attr(data-label);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        margin-right: var(--space-md);
    }

    .team-cell-primary {
        justify-content: flex-start;
    }

    .user-form-grid-2 {
        grid-template-columns: 1fr;
    }

    .user-form-section-row {
        grid-template-columns: 1fr;
    }

    .add-member-form {
        flex-direction: column;
    }

    .add-member-form .form-select,
    .add-member-form .btn {
        width: 100%;
    }
}

/* ===================================
   Auth Loading Screen
   =================================== */

.auth-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.auth-loading-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-primary);
    animation: auth-pulse 1.5s ease-in-out infinite;
}

.auth-loading-text {
    font-size: 1rem;
    color: var(--text-muted);
}

@keyframes auth-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

/* ===================================
   Schedule Components (Phase 3)
   =================================== */

/* On-Call Widget */
.on-call-overview {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* On-Call List (Table-like layout) */
.oncall-list-header {
    display: grid;
    grid-template-columns: 200px 150px 120px 120px 1fr;
    gap: var(--space-md);
    padding: 0 var(--space-md);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.oncall-list-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.oncall-row-slot {
    display: contents;
}

.oncall-row {
    display: grid;
    grid-template-columns: 200px 150px 120px 120px 1fr;
    gap: var(--space-md);
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    transition: all var(--transition-base);
}

.oncall-row:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-sm);
}

.oncall-cell {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oncall-cell-primary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    min-width: 0;
}

/* Actions column - right aligned */
.oncall-cell-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-xs);
}

.oncall-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.75rem;
}

.oncall-primary-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
}

.oncall-team-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oncall-team-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.oncall-user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.oncall-user-name.is-muted {
    font-weight: 400;
    color: var(--text-muted);
}

.oncall-until {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.oncall-until.is-muted {
    color: var(--text-muted);
}

.oncall-cell-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* On-Call Status Badge */
.oncall-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.oncall-status-badge.scheduled {
    border-color: var(--action-success);
    color: var(--action-success);
}

.oncall-status-badge.override {
    border-color: var(--severity-warning-badge);
    color: var(--severity-warning-badge);
}

.oncall-status-badge.unconfigured {
    border-color: var(--action-danger);
    color: var(--action-danger);
}

/* Delete override button inside badge */
.oncall-status-badge .delete-override-btn {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    padding: 0;
    margin-left: 2px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.oncall-status-badge .delete-override-btn:hover {
    opacity: 1;
}

.oncall-status-badge .delete-override-btn i,
.oncall-status-badge .delete-override-btn svg {
    width: 12px;
    height: 12px;
}

/* Responsive: Stack on mobile */
@media (max-width: 900px) {
    .oncall-list-header {
        display: none;
    }

    .oncall-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
        padding: var(--space-md);
    }

    .oncall-cell::before {
        content: attr(data-label);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        display: block;
        margin-bottom: 2px;
    }

    .oncall-cell-primary::before,
    .oncall-cell-actions::before {
        display: none;
    }

    .oncall-cell-actions {
        justify-content: flex-start;
    }
}

.on-call-row-slot {
    display: block;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-color);
}

.on-call-row-slot:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.on-call-row-slot:first-child {
    padding-top: 0;
}

.on-call-overview .on-call-widget.on-call-row {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
}

.on-call-row {
    display: grid;
    grid-template-columns: 160px 1fr auto;
    align-items: center;
    gap: var(--space-lg);
    min-height: 48px;
}

.on-call-row-team {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.on-call-row-main {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    color: var(--text-secondary);
    min-width: 0;
}

.on-call-row-info {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.on-call-row-name {
    font-weight: 600;
    color: var(--text-primary);
}

.on-call-row-name.is-muted {
    font-weight: 500;
    color: var(--text-muted);
}

.on-call-row-until {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.on-call-row-override {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.on-call-row-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .on-call-row {
        grid-template-columns: 1fr;
        align-items: start;
        gap: var(--space-sm);
    }

    .on-call-row-actions {
        justify-content: flex-start;
    }
}

.on-call-widget {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.on-call-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.on-call-header .on-call-icon {
    width: 16px;
    height: 16px;
    color: var(--status-resolved);
}

.on-call-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.on-call-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.on-call-user-avatar i {
    width: 24px;
    height: 24px;
}

.on-call-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.on-call-user-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.on-call-override-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--status-acknowledged-glow);
    color: var(--status-acknowledged);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.on-call-override-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: var(--space-sm);
}

.delete-override-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    line-height: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.delete-override-btn i,
.delete-override-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
}

.delete-override-btn:hover {
    border-color: var(--status-triggered);
    color: var(--status-triggered);
}

/* Small inline delete button for on-call table rows */
.on-call-row .delete-override-btn {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    border: none;
}

.on-call-row .delete-override-btn i,
.on-call-row .delete-override-btn svg {
    width: 14px;
    height: 14px;
}

.on-call-row .delete-override-btn:hover {
    border: none;
    background: transparent;
}

.on-call-until {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.on-call-l2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
}

.on-call-l2-label {
    color: var(--text-muted);
}

.on-call-l2-name {
    color: var(--text-primary);
    font-weight: 500;
}

.on-call-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* Schedule Calendar */
.schedule-calendar {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.calendar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    min-height: 80px;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day.today {
    background: var(--bg-tertiary);
}

.calendar-day-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm);
    background: var(--bg-secondary);
    font-size: 0.75rem;
}

.day-name {
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.day-date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.calendar-day.today .day-date {
    background: var(--accent-primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-day-content {
    padding: var(--space-sm);
    min-height: 40px;
}

.calendar-entry {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-entry.layer-l1 {
    background: var(--accent-primary);
    color: white;
}

.calendar-entry.layer-l2 {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
}

.calendar-entry.layer-override {
    background: rgba(212, 178, 90, 0.2);
    color: var(--severity-warning-badge);
    border: 1px solid var(--severity-warning-badge);
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.calendar-entry.layer-override:hover {
    background: rgba(212, 178, 90, 0.35);
    box-shadow: 0 0 0 2px rgba(212, 178, 90, 0.3);
}

.calendar-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Schedule Form */
.form-section {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-row {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

.form-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* User List Sortable */
.user-list-sortable {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 200px;
    overflow-y: auto;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-list-item:hover {
    background: var(--glass-bg-hover);
}

.user-list-item.selected {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.user-list-item.selected span {
    color: white;
}

/* L2 Config Toggle */
.l2-config {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: opacity var(--transition-base);
}

/* ======================================
   Schedule Config Modal - Redesigned
   ====================================== */

.schedule-config-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--space-xl);
    min-height: 400px;
}

@media (max-width: 900px) {
    .schedule-config-grid {
        grid-template-columns: 1fr;
    }
}

.schedule-settings {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.schedule-users {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Form Section with Icons */
.form-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-section-title i {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}


/* Rotation Panel */
.rotation-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.rotation-panel-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.rotation-panel-title i {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

/* Two Column Layout for Users */
.rotation-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.rotation-column {
    display: flex;
    flex-direction: column;
}

.rotation-column-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
    padding: 0 var(--space-sm);
    min-height: 32px;
}

.rotation-hint {
    display: block;
    font-size: 0.625rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    opacity: 0.7;
}

.rotation-list {
    min-height: 150px;
    max-height: 250px;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.rotation-list-selected {
    border-color: var(--accent-primary);
    border-style: solid;
    background: rgba(99, 102, 241, 0.05);
}

.rotation-list:empty::after {
    content: "Drag users here";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* User Item in Rotation */
.rotation-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: all var(--transition-fast);
}

.rotation-user:hover {
    background: var(--glass-bg-hover);
    border-color: var(--accent-primary);
}

.rotation-user:active {
    cursor: grabbing;
}

.rotation-user.sortable-ghost {
    opacity: 0.4;
    background: var(--accent-primary);
}

.rotation-user.sortable-chosen {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.drag-handle {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    cursor: grab;
    flex-shrink: 0;
}

.rotation-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.rotation-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Selected list styling */
.rotation-list-selected .rotation-user {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

/* ======================================
   L1 Groups Editor (multi-oncall)
   ====================================== */

.rotation-panel-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 var(--space-md) 0;
}

.groups-editor {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.groups-editor:empty::after {
    content: "No groups configured. Click 'Add Group' to start.";
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.group-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.group-row:hover {
    border-color: var(--accent-primary);
}

.group-row.sortable-ghost {
    opacity: 0.4;
}

.group-row.sortable-chosen {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.group-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    flex-shrink: 0;
}

.group-drag-handle:active {
    cursor: grabbing;
}

.group-label {
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 64px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.group-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    flex: 1;
    min-height: 28px;
    align-items: center;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 1rem;
    line-height: 1;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chip-remove:hover {
    color: var(--severity-critical);
    background: rgba(239, 68, 68, 0.1);
}

.group-add-user {
    flex-shrink: 0;
    min-width: 130px;
    font-size: 0.8rem;
    padding: 4px 8px;
}

.group-delete {
    flex-shrink: 0;
    color: var(--text-muted);
}

.group-delete:hover {
    color: var(--severity-critical);
}

#l1-add-group {
    align-self: flex-start;
}

/* ======================================
   Overrides List in Modal
   ====================================== */

.override-modal-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.overrides-list {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.overrides-list-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.overrides-list-title i {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.overrides-list-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.override-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

.override-item:last-child {
    margin-bottom: 0;
}

.override-item-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
}

.override-item-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.override-item-time {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.override-item-reason {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.override-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Override context menu */
.override-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

.override-context-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.override-context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.override-context-menu-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.override-context-menu-item.danger:hover {
    background: rgba(var(--action-danger-rgb, 220, 53, 69), 0.15);
    color: var(--action-danger);
}

.override-context-menu-item svg {
    width: 14px;
    height: 14px;
}

.override-form-section {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.override-form-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.override-form-title i {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

/* ======================================
   Monthly Schedule Calendar
   ====================================== */

.monthly-calendar {
    max-height: 60vh;
    overflow-y: auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.calendar-legend {
    display: flex;
    gap: var(--space-md);
}

.calendar-timezone {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.calendar-timezone i {
    width: 14px;
    height: 14px;
}

.timezone-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px 24px 2px 8px;
    /* Right padding for chevron */
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    transition: all var(--transition-fast);
}

.timezone-select:hover {
    border-color: var(--text-muted);
}

.timezone-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.timezone-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.legend-item.layer-l1 {
    background: var(--accent-primary);
    color: white;
}

.legend-item.layer-l2 {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
}

.legend-item.layer-override {
    background: rgba(212, 178, 90, 0.2);
    color: var(--severity-warning-badge);
}

.calendar-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.calendar-day {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.calendar-day.is-today {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
}

.calendar-day-header {
    min-width: 80px;
    flex-shrink: 0;
}

.calendar-day-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.calendar-day-date {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.is-today .calendar-day-date {
    color: var(--accent-primary);
}

.calendar-day-entries {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    flex: 1;
}

.calendar-entry {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.calendar-entry.layer-l1 {
    background: var(--accent-primary);
    color: white;
}

.calendar-entry.layer-l2 {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
}

.calendar-entry.layer-override {
    background: rgba(212, 178, 90, 0.2);
    color: var(--severity-warning-badge);
    border: 1px solid var(--severity-warning-badge);
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.calendar-entry.layer-override:hover {
    background: rgba(212, 178, 90, 0.35);
    box-shadow: 0 0 0 2px rgba(212, 178, 90, 0.3);
}

.entry-layer {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.8;
}

.entry-user {
    font-weight: 500;
}

.entry-time {
    font-size: 0.75rem;
    opacity: 0.8;
}

.calendar-no-entry {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.schedule-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.schedule-empty i {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-md);
}

/* ===================================
   User Menu & Profile
   =================================== */

.user-menu {
    position: relative;
}

.user-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-avatar-btn:hover {
    background: var(--bg-glass);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    z-index: 200;
}

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

.user-dropdown-header {
    padding: var(--space-sm) var(--space-md);
}

.dropdown-user-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.dropdown-user-email {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-all;
}

.user-dropdown-divider {
    height: 1px;
    margin: var(--space-sm) 0;
    background: var(--border-color);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

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

.user-dropdown-logout {
    color: var(--status-triggered);
}

.user-dropdown-logout:hover {
    background: var(--status-triggered-glow);
}

/* ===================================
   Profile Modal
   =================================== */

.modal-md {
    max-width: 560px;
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.profile-section {
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.profile-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.profile-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.profile-section-title .section-icon {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.section-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.sso-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    margin-left: var(--space-xs);
}

/* Token List */
.token-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.token-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

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

.token-name {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.token-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.token-empty {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Token Form */
.token-form .form-row {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
}

.token-form .flex-1 {
    flex: 1;
}

.token-form select {
    width: auto;
    min-width: 140px;
    height: 42px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.token-form input {
    height: 42px;
}

.token-form .btn {
    height: 42px;
    white-space: nowrap;
}

/* Token Created Alert */
.token-created-alert {
    background: var(--status-acknowledged-glow);
    border: 1px solid var(--status-acknowledged);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.token-created-alert .alert-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    color: var(--status-acknowledged);
}

.token-created-alert .alert-icon {
    width: 18px;
    height: 18px;
}

.token-value {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-primary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
}

.token-value code {
    flex: 1;
    font-family: monospace;
    font-size: 0.8125rem;
    word-break: break-all;
    color: var(--text-primary);
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
}

.btn-danger {
    background: transparent;
    border-color: var(--action-danger);
    color: var(--action-danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--action-danger);
    color: white;
}

/* ===================================
   Slack Integration (Profile)
   =================================== */

.slack-integration {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-sm);
}

.slack-integration label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.slack-input-group {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.slack-input-group input {
    flex: 1;
}

.slack-connected-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm);
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--status-resolved);
}

.slack-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--status-resolved);
}

.success-icon {
    width: 20px;
    height: 20px;
}

.slack-otp-state {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.otp-input-group input {
    width: 100%;
    text-align: center;
    letter-spacing: 0.5em;
    font-size: 1.25rem;
    font-family: monospace;
}

.slack-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* ===================================
   Policy Components (Phase 4)
   =================================== */

/* Policy Scope Tabs */
.policy-scope-tabs {
    display: flex;
    gap: 0;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: var(--space-lg);
    width: fit-content;
}

.scope-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.scope-tab i {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.scope-tab:hover:not(.active) {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.scope-tab.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}

.scope-tab.active i {
    opacity: 1;
}

/* Mobile: Stack policy scope tabs vertically */
@media (max-width: 600px) {
    .policy-scope-tabs {
        flex-direction: column;
        width: 100%;
    }

    .scope-tab {
        width: 100%;
        justify-content: center;
    }
}

/* Policy Scope Badges */
.badge-global {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.3), rgba(234, 179, 8, 0.15));
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: #eab308;
}

.badge-team {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-hover);
}

[data-theme="light"] .badge-global {
    background: rgba(180, 140, 20, 0.15);
    border-color: rgba(180, 140, 20, 0.35);
    color: #a97c08;
}

[data-theme="light"] .badge-team {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.25);
    color: var(--accent-primary);
}

/* Read-only banner for global policies */
.policy-readonly-banner {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.25);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.policy-readonly-banner i {
    width: 16px;
    height: 16px;
    color: #eab308;
}

/* Policy Scope Tabs (compact, for editor) */
.scope-tabs-sm {
    display: inline-flex;
    gap: 2px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.scope-tab-sm {
    padding: 6px 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: calc(var(--radius-lg) - 6px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.scope-tab-sm:hover:not(.active):not(:disabled) {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.scope-tab-sm.active {
    background: var(--glass-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.scope-tab-sm:disabled,
.scope-tab-sm.disabled {
    cursor: not-allowed;
}

.scope-tab-sm:disabled:not(.active),
.scope-tab-sm.disabled:not(.active) {
    opacity: 0.4;
}

.scope-tab-sm.active:disabled {
    opacity: 1;
}

.form-group .scope-tabs-sm {
    align-self: flex-start;
}

.scope-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.scope-option:hover:not(.disabled) {
    background: var(--bg-glass);
    border-color: var(--glass-border-hover);
}

.scope-option.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
}

.scope-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.scope-option input[type="radio"] {
    accent-color: var(--accent-primary);
    margin: 0;
    margin-top: 4px;
    width: 16px;
    height: 16px;
}

.scope-option-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scope-option-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.scope-option-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Policies Grid */
.policies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-md);
}

/* Integrations Grid */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-md);
}

.integrations-grid .empty-state,
.policies-grid .empty-state {
    grid-column: 1 / -1;
    text-align: center;
}

/* Input with Copy Button */
.input-with-copy {
    display: flex;
    gap: var(--space-sm);
}

.input-with-copy input {
    flex: 1;
}

.input-with-copy .copy-btn,
.input-with-copy .copy-url-btn {
    flex-shrink: 0;
}

/* Policy Card */
.policy-card {
    display: flex;
    flex-direction: column;
    word-break: break-word;
    overflow-wrap: break-word;
}

.policy-card .policy-steps-preview {
    min-height: 32px;
}

/* Policy card overflow handling */
.policy-card-header,
.policy-card-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 600px) {
    .policy-card {
        min-width: 0;
    }

    .policy-steps-preview {
        flex-wrap: wrap;
    }

    .step-chip {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
}

/* Scope display for locked editing state */
.scope-display {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    cursor: not-allowed;
    padding: var(--space-sm) var(--space-md);
    box-sizing: border-box;
    font-size: 0.9rem;
}

.policy-builder .scope-display {
    background: var(--bg-primary);
}

/* Step Chips */
.step-chips-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.step-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.step-chip.step-start {
    background: var(--status-resolved);
}

.step-delay {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-style: italic;
}

.step-arrow {
    color: var(--text-muted);
}

/* Policy Builder Modal */
.policy-builder {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: var(--space-md);
    margin-right: calc(-1 * var(--space-md));
}

/* Scrollbar styling for policy builder */
.policy-builder::-webkit-scrollbar {
    width: 8px;
}

.policy-builder::-webkit-scrollbar-track {
    background: transparent;
}

.policy-builder::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.policy-builder::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.policy-builder-alert {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid var(--status-acknowledged);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    font-size: 0.9rem;
}

.policy-builder-alert i {
    flex-shrink: 0;
    color: var(--status-acknowledged);
    width: 18px;
    height: 18px;
}

/* Policy Meta Section */
.policy-meta-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

/* Policy Form Elements */
.policy-builder .form-group {
    margin-bottom: var(--space-md);
}

.policy-builder .form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.policy-builder .form-input,
.policy-builder .form-select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.policy-builder .form-input:focus,
.policy-builder .form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.policy-builder textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Policy Steps Section */
.policy-steps-section h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.policy-steps-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

/* Policy Step Row - Card Style */
.policy-step-row {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.policy-step-row:last-child {
    margin-bottom: 0;
}

.policy-step-row:hover {
    border-color: var(--accent-primary);
}

/* Sortable styles */
.policy-step-row.sortable-ghost {
    opacity: 0.4;
}

.policy-step-row.sortable-chosen {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.2);
}

/* Step Header */
.step-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.step-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-left: auto;
}

/* Toggle Switch (iOS-style) */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: all var(--transition-fast);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::after {
    left: 18px;
    background: white;
}

.toggle-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

#integration-config-fields .toggle-text {
    font-size: 0.875rem;
    white-space: normal;
}

.step-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 4px;
    transition: color var(--transition-fast);
}

.step-drag-handle:hover {
    color: var(--text-primary);
}

.step-drag-handle:active {
    cursor: grabbing;
}

.step-drag-handle i {
    width: 16px;
    height: 16px;
    display: block;
}

.step-index-label {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.875rem;
    flex: 1;
}

.step-header .remove-step-btn {
    color: var(--text-muted);
    background: transparent;
    border: none;
    opacity: 0.6;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}

.step-header .remove-step-btn:hover {
    opacity: 1;
    color: var(--status-triggered);
}

.step-header .remove-step-btn i {
    width: 14px;
    height: 14px;
}

/* Step Fields Grid */
.step-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.step-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.step-field .form-input,
.step-field .form-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color var(--transition-fast);
}

.step-field .form-input:focus,
.step-field .form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Step Timing Row */
.step-timing {
    display: grid;
    grid-template-columns: 80px 80px 80px 1fr;
    gap: var(--space-md);
    padding-top: var(--space-sm);
    border-top: 1px dashed var(--border-color);
}

.step-field-sm .form-input {
    text-align: center;
}

.step-field-message {
    grid-column: 4;
}

/* Variables Hint */
.variables-hint {
    color: var(--text-muted);
    cursor: help;
    font-size: 0.8rem;
    margin-left: 4px;
}

.variables-hint:hover {
    color: var(--accent-primary);
}

/* Policy Builder Footer */
.policy-builder-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* Duplicate Policy Form */
.duplicate-policy-form {
    padding: var(--space-md);
}

.duplicate-policy-form h3 {
    margin-bottom: var(--space-lg);
}

.duplicate-policy-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

/* Light theme */
[data-theme="light"] .policy-step-row {
    background: white;
}

[data-theme="light"] .policy-steps-list {
    background: var(--bg-tertiary);
}

[data-theme="light"] .step-field .form-input,
[data-theme="light"] .step-field .form-select {
    background: var(--bg-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .policy-meta-section {
        grid-template-columns: 1fr;
    }

    .step-fields {
        grid-template-columns: 1fr;
    }

    .step-timing {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .step-field-message {
        grid-column: 1 / -1;
    }

    .step-header {
        flex-wrap: wrap;
    }

    .step-header-actions {
        gap: var(--space-sm);
    }

    .header-actions {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .step-header-actions .toggle-text {
        display: none;
    }
}

/* Extra small screens */
@media (max-width: 600px) {
    .step-timing {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }

    .step-timing .step-field {
        min-width: 0;
    }
}

/* ===================================
   Sidebar Controls (Mode Switcher & Team Selector)
   =================================== */

/* MODE Section - Top-level global mode switch */
.mode-section {
    padding: var(--space-md);
    background: var(--bg-primary);
    border-bottom: 2px solid var(--accent-primary);
}

.mode-section-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    padding-left: 2px;
}

.mode-switcher {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.mode-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-btn .mode-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.mode-btn:hover:not(.disabled):not(:disabled) {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.mode-btn.active .mode-icon {
    stroke-width: 2.5;
}

.mode-btn.disabled,
.mode-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* Team Context Wrapper (sidebar) */
.team-context-wrapper {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

/* Team Context Selector within wrapper */
.team-context-wrapper .team-selector {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.team-context-wrapper .team-selector:hover {
    border-color: var(--accent-primary);
    background: var(--bg-glass);
}

.team-label-prefix {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 4px;
}

/* Standalone Team Selector (fallback for old structure) */
.team-selector {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
    user-select: none;
}

.team-selector:hover {
    background: var(--bg-tertiary);
}

.team-selector-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* Dropdown */
.sidebar-header-controls {
    position: relative;
}

.team-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: var(--space-md);
    right: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    animation: fadeIn 0.1s ease-out;
}

.team-selector.active+.team-dropdown,
.sidebar-header-controls.active .team-dropdown,
.context-section.active .team-dropdown,
.team-context-wrapper.active .team-dropdown {
    display: block;
}

.team-dropdown-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.team-dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.team-dropdown-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    font-weight: 500;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.team-icon-small {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.team-icon-small i {
    width: 14px;
    height: 14px;
}

/* Configure Dashboard Tiles */
.configure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.config-tile {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.config-tile:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

.config-tile.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.config-tile .tile-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}

.config-tile h3 {
    margin: 0;
    font-size: 1.1rem;
}

.config-tile p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Delivery Status Badges */
.delivery-status {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.delivery-status-pending {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.delivery-status-retry {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.delivery-status-sent {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
}

.delivery-status-failed {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

[data-theme="light"] .delivery-status-pending {
    background: rgba(180, 140, 20, 0.15);
    color: #a97c08;
}

[data-theme="light"] .delivery-status-retry {
    background: rgba(200, 90, 15, 0.15);
    color: #c45a0f;
}

[data-theme="light"] .delivery-status-sent {
    background: rgba(5, 120, 80, 0.12);
    color: #047857;
}

[data-theme="light"] .delivery-status-failed {
    background: rgba(180, 30, 30, 0.12);
    color: #b91c1c;
}

/* Delivery table */
.delivery-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.delivery-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.delivery-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.delivery-table tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.delivery-table tbody tr:hover {
    background: var(--bg-glass);
}

.delivery-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.delivery-detail-meta dt {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.delivery-detail-meta dd {
    margin: 0 0 var(--space-sm) 0;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.delivery-payload {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    overflow-x: auto;
    font-family: var(--font-mono, monospace);
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
}

/* ===================================
   Timezone Picker
   =================================== */

.tz-picker {
    position: relative;
}

.tz-picker-display {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    text-align: left;
}

.tz-picker-display:hover {
    border-color: var(--text-muted);
}

.tz-picker-display:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.tz-picker-display.is-open {
    border-color: var(--accent-primary);
}

.tz-picker-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tz-picker-offset {
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.tz-picker-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.tz-picker-display.is-open .tz-picker-chevron {
    transform: rotate(180deg);
}

.tz-picker-dropdown {
    position: fixed;
    z-index: 10000;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: fadeIn var(--transition-fast);
}

.tz-picker-search {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
}

.tz-picker-search::placeholder {
    color: var(--text-muted);
}

.tz-picker-list {
    max-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.tz-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--space-md);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background var(--transition-fast);
}

.tz-picker-item:hover,
.tz-picker-item.is-highlighted {
    background: var(--glass-bg-hover);
}

.tz-picker-item.is-selected {
    background: rgba(99, 102, 241, 0.12);
}

.tz-picker-item.is-selected .tz-picker-item-name {
    color: var(--accent-hover);
}

.tz-picker-item-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tz-picker-item-offset {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
    margin-left: var(--space-sm);
}

.tz-picker-local-badge {
    display: inline-block;
    font-size: 0.625rem;
    padding: 0 4px;
    border-radius: 3px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-hover);
    vertical-align: middle;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tz-picker-empty {
    padding: var(--space-md);
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

/* Calendar-inline variant — smaller, transparent style */
.calendar-timezone .tz-picker {
    min-width: 150px;
}

.calendar-timezone .tz-picker-display {
    background: transparent;
    border-color: var(--border-color);
    padding: 2px 8px;
    font-size: 0.8125rem;
}

.calendar-timezone .tz-picker-display:hover {
    border-color: var(--text-muted);
}

/* tz-picker scrollbar */
.tz-picker-list::-webkit-scrollbar {
    width: 6px;
}

.tz-picker-list::-webkit-scrollbar-track {
    background: transparent;
}

.tz-picker-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}