/* Root Variables - Purple / Coral Theme (Dark - Default) */
:root {
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #24243e;
    --bg-hover: #2d2d4a;

    --text-primary: #e8eaed;
    --text-secondary: #b8bcc8;
    --text-muted: #6e7491;

    --accent-primary: #9c6ade;
    --accent-secondary: #b794f6;
    --accent-tertiary: #d4556b;
    --accent-glow: rgba(156, 106, 222, 0.25);

    --error: #f87171;
    --warning: #fbbf24;
    --success: #4ade80;
    --info: #60a5fa;

    --border-color: #2d2d4a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 15px var(--accent-glow);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Fira Code', 'Consolas', monospace;

    --transition: all 0.15s ease;

    /* Dracula-inspired syntax highlighting */
    --syntax-keyword: #ff79c6;
    --syntax-function: #50fa7b;
    --syntax-string: #f1fa8c;
    --syntax-number: #bd93f9;
    --syntax-operator: #ff79c6;
    --syntax-comment: #6272a4;
    --syntax-key: #8be9fd;

    /* Chart / canvas colors (used by JS) */
    --chart-text: #e8eaed;
    --chart-text-secondary: #b8bcc8;
    --chart-bg: #1a1a2e;
    --chart-border: #24243e;
    --chart-grid: #24243e;
    --chart-grid-half: rgba(36, 36, 62, 0.5);
    --chart-accent: #9c6ade;
    --chart-accent-dark: #8b5fbf;

    /* Timeline canvas */
    --timeline-bar-start: #b794f6;
    --timeline-bar-end: #9c6ade;
    --timeline-text: #6e7491;
    --timeline-selection: rgba(156, 106, 222, 0.3);
    --timeline-selection-border: #9c6ade;

    /* Network graph */
    --graph-node-parent: #6366f1;
    --graph-node-child: #d4556b;
    --graph-node-parent-hover: #818cf8;
    --graph-node-child-hover: #e06b80;
    --graph-edge: #9c6ade;
    --graph-label: #ffffff;
    --graph-label-stroke: #000000;
    --graph-edge-1: #9c6ade;
    --graph-edge-2: #d4556b;
    --graph-edge-3: #22d3ee;
    --graph-edge-4: #f59e0b;
    --graph-edge-5: #ef4444;
    --graph-edge-6: #10b981;

    /* World map */
    --worldmap-marker: #9c6ade;
    --worldmap-marker-glow: rgba(156, 106, 222, 0.4);

    /* Overlay tints for interactive elements */
    --overlay-subtle: rgba(255, 255, 255, 0.05);
    --overlay-light: rgba(255, 255, 255, 0.08);
    --overlay-border: rgba(255, 255, 255, 0.1);
    --overlay-border-hover: rgba(255, 255, 255, 0.2);

    /* Scrollbar */
    --scrollbar-track: var(--bg-secondary);
    --scrollbar-thumb: var(--bg-hover);
}

/* Light Theme - Azure / Tan / Orange */
[data-theme="light"] {
    --bg-primary: #faf8f5;
    --bg-secondary: #f0ece6;
    --bg-tertiary: #e6e0d8;
    --bg-hover: #ddd6cc;

    --text-primary: #1a1612;
    --text-secondary: #3d3730;
    --text-muted: #7a7268;

    --accent-primary: #2563b5;
    --accent-secondary: #1d4f91;
    --accent-tertiary: #c2650a;
    --accent-glow: rgba(37, 99, 181, 0.15);

    --error: #dc2626;
    --warning: #b45309;
    --success: #16a34a;
    --info: #2563eb;

    --border-color: #d6cfc6;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 15px var(--accent-glow);

    /* Light-friendly syntax highlighting */
    --syntax-keyword: #af3685;
    --syntax-function: #16803c;
    --syntax-string: #8a6d10;
    --syntax-number: #7c3aed;
    --syntax-operator: #af3685;
    --syntax-comment: #7a7268;
    --syntax-key: #0e6f9e;

    /* Chart / canvas colors */
    --chart-text: #1a1612;
    --chart-text-secondary: #3d3730;
    --chart-bg: #f0ece6;
    --chart-border: #d6cfc6;
    --chart-grid: #d6cfc6;
    --chart-grid-half: rgba(214, 207, 198, 0.5);
    --chart-accent: #2563b5;
    --chart-accent-dark: #1d4f91;

    /* Timeline canvas */
    --timeline-bar-start: #3b82f6;
    --timeline-bar-end: #2563b5;
    --timeline-text: #7a7268;
    --timeline-selection: rgba(37, 99, 181, 0.15);
    --timeline-selection-border: #2563b5;

    /* Network graph */
    --graph-node-parent: #2563b5;
    --graph-node-child: #c2650a;
    --graph-node-parent-hover: #3b82f6;
    --graph-node-child-hover: #d97706;
    --graph-edge: #2563b5;
    --graph-label: #1a1612;
    --graph-label-stroke: #faf8f5;
    --graph-edge-1: #2563b5;
    --graph-edge-2: #c2650a;
    --graph-edge-3: #0891b2;
    --graph-edge-4: #b45309;
    --graph-edge-5: #dc2626;
    --graph-edge-6: #16a34a;

    /* World map */
    --worldmap-marker: #2563b5;
    --worldmap-marker-glow: rgba(37, 99, 181, 0.3);

    /* Overlay tints */
    --overlay-subtle: rgba(0, 0, 0, 0.03);
    --overlay-light: rgba(0, 0, 0, 0.05);
    --overlay-border: rgba(0, 0, 0, 0.1);
    --overlay-border-hover: rgba(0, 0, 0, 0.18);

    /* Scrollbar */
    --scrollbar-track: var(--bg-secondary);
    --scrollbar-thumb: #c4bdb4;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    resize: none !important;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 100%;
    margin: 0;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Header */
.header {
    margin-bottom: 0.5rem;
    padding-bottom: 0;
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-left: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

.logo:hover {
    opacity: 0.8;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary), var(--accent-tertiary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8125rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.status-connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.status-disconnected {
    background: var(--error);
    animation: none;
}

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

.status-text {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.status-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.active,
.modal[style*="display: flex"] {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

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

.modal-body {
    padding: 1.25rem;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.status-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.status-section h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.8125rem;
}

.status-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.status-item:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

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

.status-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
}

.status-ok {
    color: #10b981;
}

.status-error {
    color: #ef4444;
}

.danger-section {
    background: rgba(248, 113, 113, 0.05);
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid rgba(248, 113, 113, 0.2);
    margin-top: 0.5rem;
}

.warning-text {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

.danger-btn {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--error);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.danger-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3);
}

.danger-btn:active {
    transform: translateY(0);
}

/* Fractal Details Modal */
.fractal-details-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
}

.detail-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--overlay-subtle);
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-row.highlight {
    background: rgba(65, 105, 225, 0.05);
    padding: 0.75rem;
    margin: 0 -0.25rem;
    border-radius: 4px;
    border-bottom: none;
}

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

.detail-value {
    color: var(--text-primary);
    font-weight: 400;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.fractal-settings {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.fractal-settings h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.management-actions {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.management-actions h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-buttons .btn-secondary,
.action-buttons .btn-danger {
    flex: 1;
    min-width: 140px;
}

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

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn-secondary,
    .action-buttons .btn-danger {
        flex: none;
    }
}

.danger-section {
    background: var(--bg-tertiary);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.danger-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--error);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
}

.danger-warning {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.fractal-manage-view {
    padding: 2rem;
    max-width: 100%;
    margin: 0;
}

.manage-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.manage-title-row h2 {
    margin: 0;
    padding: 0;
    border: none;
}

.fractal-manage-view h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.manage-edit-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.manage-edit-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.danger-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.danger-action-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(239, 68, 68, 0.1);
}

.danger-action-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.danger-action-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.danger-action-label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.danger-action-desc {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.danger-action-item .danger-btn {
    width: auto;
    min-width: 100px;
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* Settings */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
}

.icon-btn:hover {
    background: rgba(156, 106, 222, 0.1);
    color: var(--accent-color);
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.setting-info {
    flex: 1;
    margin-right: 1rem;
}

.setting-label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.setting-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.setting-description code {
    background: rgba(156, 106, 222, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-color);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #10b981;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-primary {
    padding: 0.625rem 1.5rem;
    background: var(--accent-color);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(156, 106, 222, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Search Section */
.search-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.625rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-sm);
}

/* Toolbar: all controls in one row above the query input */
.search-toolbar {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.375rem;
    position: relative;
}

.toolbar-separator {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 0.125rem;
}

.toolbar-spacer {
    flex: 1;
}

.toolbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.toolbar-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.query-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

/* Drag handle to resize query input */
.query-resize-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 8px;
    cursor: ns-resize;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.query-resize-handle::after {
    content: '';
    width: 32px;
    height: 3px;
    border-radius: 2px;
    background: var(--text-muted);
}

.query-resize-handle:hover {
    opacity: 0.7;
}

.query-input-wrapper {
    flex: 1;
    position: relative;
    min-height: 38px;
    z-index: 0;
    isolation: isolate;
}

/* Line number gutter */
.query-line-numbers {
    position: absolute;
    top: 1px;
    left: 1px;
    bottom: 1px;
    width: 2.5rem;
    padding: 0.625rem 0.375rem 0.625rem 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: right;
    overflow: hidden;
    pointer-events: none;
    white-space: pre;
    z-index: 3;
    user-select: none;
    box-sizing: border-box;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
}

.query-highlight {
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    padding: 0.625rem 0.875rem 0.625rem 3rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: transparent;
    background: transparent;
    border: none;
    border-radius: 4px;
    pointer-events: none;
    white-space: pre-wrap;
    overflow: hidden;
    z-index: 1;
    margin: 0;
    box-sizing: border-box;
}

/* Default text color for unhighlighted content */
.query-highlight .hl-default {
    color: var(--text-primary);
}

/* Allow normal text selection - some visual artifacts are acceptable */

.search-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.625rem 0.875rem 0.625rem 3rem;
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    color: transparent;
    caret-color: var(--text-primary);
    transition: var(--transition);
    resize: none;
    min-height: 38px;
    max-height: 400px;
    line-height: 1.5;
    z-index: 0;
    margin: 0;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.query-input-wrapper:focus-within .query-highlight {
    border-color: var(--accent-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.search-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
}

.search-btn:active:not(:disabled) {
    opacity: 0.85;
}

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

.search-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-loader {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--overlay-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Query Mode Toggle */
/* Time Range */

.time-range-select,
.datetime-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.375rem 0.625rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    transition: var(--transition);
    width: 138px;
}

.time-range-select {
    font-family: var(--font-main);
    font-size: 0.8125rem;
    width: auto;
}

.time-range-select:focus,
.datetime-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.setting-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8125rem;
    transition: var(--transition);
    cursor: pointer;
}

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

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

/* Form Input Styling */
.form-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.625rem 0.875rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8125rem;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.custom-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-separator {
    color: var(--text-muted);
}

/* Timeline (inline in results) */
.timeline-inline {
    position: relative;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.375rem;
}

.timeline-inline-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.675rem;
    color: var(--text-muted);
    padding-top: 0.25rem;
    font-family: var(--font-mono);
    letter-spacing: 0.01em;
}

#timeline {
    width: 100%;
    height: 44px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    cursor: crosshair;
    user-select: none;
    display: block;
}

.timeline-tooltip {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    line-height: 1.3;
    display: none;
}

.timeline-tooltip strong {
    color: var(--accent-secondary);
    font-size: 0.8125rem;
}

#mainView,
#fractalView,
#fractalListingTabContent,
#fractalSearchTabContent {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Lock viewport height when search view is active so results scroll internally */
body.search-active {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#searchView {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#searchView .results-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#searchView .results-container {
    flex: 1;
    min-height: 0;
}

/* Results Section */
.results-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.625rem 0.75rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    flex: 1;
    min-height: 0;
}

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

.results-header h2 {
    font-size: 1rem;
    font-weight: 500;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.result-count {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.execution-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    display: none;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.export-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

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

/* Error Message */
.error-message {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--error);
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    color: var(--error);
    font-size: 0.8125rem;
}

.error-message:empty {
    display: none;
}

/* Sigma Detection Info */
.sigma-info {
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 4px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-tertiary);
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

/* SQL Preview */
.sql-preview {
    display: none; /* Hidden by default until after query execution */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.8125rem;
}

.sql-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sql-preview strong {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toggle-sql-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-sql-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.sql-preview code {
    display: block;
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-size: 0.75rem;
    overflow-x: auto;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 3px;
    margin-top: 0.5rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* SQL Syntax highlighting */
.sql-keyword {
    color: var(--syntax-keyword);
    font-weight: 500;
}

.sql-function {
    color: var(--syntax-function);
}

.sql-string {
    color: var(--syntax-string);
}

.sql-number {
    color: var(--syntax-number);
}

.sql-operator {
    color: var(--syntax-operator);
}

/* Results Container */
.results-container {
    overflow-y: auto;
    min-height: 0;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    gap: 0.75rem;
}

.empty-state svg {
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.875rem;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.results-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-tertiary);
}

.results-table th {
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    background: var(--bg-tertiary);
}

.results-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.results-table th.sortable:hover {
    color: var(--accent-color);
    background: rgba(156, 106, 222, 0.05);
}

/* Column resizing */
.results-table th {
    position: relative;
    user-select: none;
}

.results-table th.resizing {
    user-select: none;
}

.column-resizer {
    display: none !important;
}

.column-resizer:hover {
    background: var(--accent-primary);
}

.results-table th.dragging {
    opacity: 0.5;
}

.results-table th.drag-over {
    border-left: 3px solid var(--accent-primary);
}

.results-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.results-table tbody tr:hover {
    background: var(--bg-hover);
}

.results-table tbody tr.has-comments {
    border-left: 2px solid var(--accent-color, rgba(156, 106, 222, 0.7)) !important;
}

.results-table tbody tr.has-comments td:first-child {
    position: relative;
    padding-left: 1.5rem;
}

.results-table tbody tr.has-comments td:first-child::before {
    content: '';
    position: absolute;
    left: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239c6ade' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.7;
}

.results-table tbody tr.has-comments:hover {
    background: var(--bg-hover) !important;
}

.results-table tbody tr:last-child {
    border-bottom: none;
}

.results-table td {
    padding: 0.625rem 0.75rem;
    color: var(--text-primary);
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timestamp-cell {
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 0.75rem;
    width: 1%;
    padding-right: 1rem !important;
}

.json-cell {
    font-family: var(--font-mono);
}

.json-value {
    background: var(--bg-primary);
    padding: 0.25rem 0.375rem;
    border-radius: 3px;
    font-size: 0.75rem;
    margin: 0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* JSON Syntax highlighting */
.json-key {
    color: var(--syntax-key);
}

.json-string {
    color: var(--syntax-string);
}

.json-number {
    color: var(--syntax-number);
}

.json-boolean {
    color: var(--syntax-keyword);
}

.json-bracket {
    color: var(--text-secondary);
    font-weight: 600;
}

.null-cell {
    color: var(--text-muted);
    font-style: italic;
}

/* Level highlighting */
.level-error {
    color: var(--error);
    font-weight: 500;
}

.level-warn {
    color: var(--warning);
    font-weight: 500;
}

.level-info {
    color: var(--info);
    font-weight: 500;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }

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

    .search-section,
    .results-section,
    .timeline-section {
        padding: 0.75rem;
    }

    .query-controls-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .query-input-row {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .query-input-wrapper {
        width: 100%;
    }

    .time-range-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .time-controls-left {
        justify-content: center;
    }

    .time-controls-right {
        margin-left: 0;
        justify-content: center;
    }

    .search-btn {
        width: 32px;
        margin-left: 0;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .results-table {
        font-size: 0.75rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem 0.375rem;
    }
}
/* Append these to the existing style.css */

/* Legacy button aliases */
.recent-queries-btn { /* see .toolbar-icon-btn */ }
.share-query-btn { /* see .toolbar-icon-btn */ }

/* Recent Queries Dropdown */
.recent-queries-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 500px;
    max-width: calc(100% - 1rem);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    margin-top: 0.5rem;
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-search {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    transition: var(--transition);
}

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

.dropdown-search::placeholder {
    color: var(--text-muted);
}

.clear-recent-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    transition: var(--transition);
    line-height: 1;
}

.clear-recent-btn:hover {
    background: var(--bg-hover);
    color: var(--error);
}

.dropdown-list {
    max-height: 300px;
    overflow-y: auto;
}

.recent-query-item {
    padding: 0.625rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-query-item:last-child {
    border-bottom: none;
}

.recent-query-item:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.recent-query-item.hidden {
    display: none;
}

.dropdown-list .empty-message {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Saved Queries Dropdown */
.saved-queries-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 500px;
    max-width: calc(100% - 1rem);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    margin-top: 0.5rem;
}

.saved-query-item {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    transition: var(--transition);
}

.saved-query-item:last-child {
    border-bottom: none;
}

.saved-query-item:hover {
    background: var(--bg-hover);
}

.saved-query-item .sq-main {
    cursor: pointer;
    padding-right: 3.5rem;
}

.saved-query-item .sq-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.saved-query-item .sq-preview {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-query-item .sq-tags {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.saved-query-item .sq-tag {
    font-size: 0.6875rem;
    padding: 0.0625rem 0.375rem;
    border-radius: 3px;
    background: rgba(156, 106, 222, 0.2);
    color: var(--accent-secondary);
}

.saved-query-item .sq-actions {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 0.25rem;
}

.saved-query-item:hover .sq-actions {
    display: flex;
}

.sq-action-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.sq-action-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.sq-action-btn.delete:hover {
    color: var(--error);
    border-color: var(--error);
}

.sq-form {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sq-form-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    box-sizing: border-box;
}

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

.sq-form-input::placeholder {
    color: var(--text-muted);
}

.sq-form-textarea {
    resize: vertical;
    min-height: 3rem;
    max-height: 8rem;
}

.sq-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.saved-query-item.editing {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--accent-primary);
}

/* Autocomplete */
.autocomplete {
    position: absolute;
    top: 100%;
    left: 3rem;
    right: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.autocomplete-item .syntax-keyword {
    color: var(--syntax-function);
    font-weight: 500;
}

.autocomplete-item .syntax-desc {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.autocomplete-item .syntax-field {
    color: var(--accent-color, #9c6ade);
    font-weight: 500;
}

.autocomplete-item .syntax-value {
    color: var(--text-primary);
    font-weight: 400;
}

/* Function hint popup (? key) */
.function-hint {
    display: none;
    position: fixed;
    max-width: 480px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.625rem 0.75rem;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.fn-hint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.375rem;
    gap: 0.5rem;
}

.fn-hint-signature {
    color: var(--accent-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fn-hint-dismiss {
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.125rem;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.fn-hint-dismiss:hover {
    opacity: 1;
    color: var(--text-primary);
}

.fn-hint-args {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin-bottom: 0.375rem;
}

.fn-hint-arg {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.fn-arg-name {
    flex-shrink: 0;
    font-weight: 500;
}

.fn-arg-name.fn-arg-required {
    color: var(--accent-primary);
}

.fn-arg-name.fn-arg-optional {
    color: var(--text-muted);
}

.fn-arg-desc {
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.6875rem;
}

.fn-hint-example {
    color: var(--text-muted);
    font-size: 0.6875rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pagination */
.page-size-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-btn {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

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

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

/* Log Detail Side Panel */
/* Left Panel (Log Details) */
.left-panel {
    position: fixed;
    left: -550px;
    top: 0;
    width: 550px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
    transition: left 0.3s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.left-panel.open {
    left: 0;
}

/* Right Panel (Comments) */
.right-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease;
    z-index: 998;
    display: flex;
    flex-direction: column;
}

.right-panel.open {
    right: 0;
}

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

.panel-header h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.left-panel .panel-header,
.right-panel .panel-header {
    padding: 0.5rem 0.75rem;
}

.left-panel .panel-header h3,
.right-panel .panel-header h3 {
    font-size: 0.875rem;
}

.close-panel-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

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

.send-to-chat-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    opacity: 0.5;
    transition: all 0.2s ease;
}

.send-to-chat-btn:hover {
    background: rgba(156, 106, 222, 0.1);
    color: var(--accent-color);
    opacity: 1;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

#logDetailContent.panel-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.log-field {
    padding: 0.3rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.log-field:last-child {
    border-bottom: none;
}

.log-field-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    margin-bottom: 0.125rem;
    font-family: var(--font-mono);
}

.log-field-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.3;
}

.log-field-value-row {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
}

.log-field-value-text {
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.log-field-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.log-field:hover .log-field-actions {
    opacity: 1;
}

.log-field-actions .fs-action-btn {
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

.log-field-actions .fs-filter-in:hover {
    color: var(--success);
    border-color: var(--success);
}

.log-field-actions .fs-filter-out:hover {
    color: var(--error);
    border-color: var(--error);
}

.log-field-copy-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 1px 3px;
    flex-shrink: 0;
    transition: opacity 0.15s, color 0.15s;
    line-height: 1;
}

.log-field:hover .log-field-copy-btn {
    opacity: 1;
}

.log-field-actions .log-field-copy-btn {
    opacity: 1;
}

.log-field-copy-btn:hover {
    color: var(--accent-color);
}

.log-field-copy-btn.copied {
    color: var(--success-color, #22c55e);
    opacity: 1;
}

.log-field-value.json {
    position: relative;
    background: var(--bg-primary);
    padding: 0.375rem;
    border-radius: 4px;
    overflow-x: auto;
}

.log-field-value.json pre {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Log Detail Tabs */
.log-detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    padding: 0 0.5rem;
}

.log-detail-tab {
    padding: 0.375rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

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

.log-detail-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.log-detail-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.log-detail-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Log Detail Search */
.log-detail-search {
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.log-detail-search-input {
    width: 100%;
    padding: 0.3rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    transition: border-color 0.2s;
}

.log-detail-search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.log-detail-search-input::placeholder {
    color: var(--text-muted);
}

.log-fields-container {
    flex: 1;
    overflow-y: auto;
}

/* Raw Log Tab */
.raw-log-content {
    position: relative;
    padding: 0.5rem 0.75rem;
    flex: 1;
    overflow: auto;
}

.raw-log-content pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.raw-log-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    transition: opacity 0.15s, color 0.15s;
}

.raw-log-content:hover .raw-log-copy-btn {
    opacity: 1;
}

.raw-log-copy-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.raw-log-copy-btn.copied {
    color: var(--success-color, #22c55e);
    border-color: var(--success-color, #22c55e);
    opacity: 1;
}

.json-copy-btn {
    position: absolute;
    top: 4px;
    right: 4px;
}

.log-field:hover .json-copy-btn {
    opacity: 1;
}

/* Bottom Time Bar */
.time-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    z-index: 100;
    padding: 0 1rem;
}

.time-bar-left {
    justify-self: start;
}

.time-bar-center {
    justify-self: center;
}

.time-bar-right {
    justify-self: end;
}

/* Timestamp hover tooltip */
.timestamp-cell {
    position: relative;
    cursor: help;
}

.timestamp-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    margin-bottom: 0.25rem;
}

.timestamp-cell:hover .timestamp-tooltip {
    opacity: 1;
}

/* Query syntax highlighting */
.query-highlight .hl-function {
    color: var(--syntax-function);
    font-weight: 500;
}

.query-highlight .hl-operator {
    color: var(--syntax-operator);
}

.query-highlight .hl-keyword {
    color: var(--syntax-keyword);
    font-weight: 500;
}

.query-highlight .hl-string {
    color: var(--syntax-string);
}

.query-highlight .hl-pipe {
    color: var(--syntax-operator);
    font-weight: 600;
}

.query-highlight .hl-field {
    color: var(--info);
}

.query-highlight .hl-value {
    color: var(--syntax-string);
}

.query-highlight .hl-regex {
    color: #c084fc;
    font-weight: 500;
}

.query-highlight .hl-assignment {
    color: var(--syntax-operator);
    font-weight: 600;
}

.query-highlight .hl-number {
    color: var(--syntax-number);
}

.query-highlight .hl-bracket {
    color: var(--text-secondary);
    font-weight: 500;
}

.query-highlight .hl-boolean {
    color: var(--syntax-keyword);
    font-weight: 500;
}

.query-highlight .hl-wildcard {
    color: var(--warning);
    font-weight: 600;
}

.query-highlight .hl-comment {
    color: var(--syntax-comment);
    font-style: italic;
}

/* Syntax highlighting for display mode (notebooks) */
.query-display .hl-default {
    color: var(--text-primary);
}

.query-display .hl-function {
    color: var(--syntax-function);
    font-weight: 500;
}

.query-display .hl-operator {
    color: var(--syntax-operator);
}

.query-display .hl-keyword {
    color: var(--syntax-keyword);
    font-weight: 500;
}

.query-display .hl-string {
    color: var(--syntax-string);
}

.query-display .hl-pipe {
    color: var(--syntax-operator);
    font-weight: 600;
}

.query-display .hl-field {
    color: var(--info);
}

.query-display .hl-value {
    color: var(--syntax-string);
}

.query-display .hl-regex {
    color: #c084fc;
    font-weight: 500;
}

.query-display .hl-assignment {
    color: var(--syntax-operator);
    font-weight: 600;
}

.query-display .hl-number {
    color: var(--syntax-number);
}

.query-display .hl-bracket {
    color: var(--text-secondary);
    font-weight: 500;
}

.query-display .hl-boolean {
    color: var(--syntax-keyword);
    font-weight: 500;
}

.query-display .hl-wildcard {
    color: var(--warning);
    font-weight: 600;
}

.query-display .hl-comment {
    color: var(--syntax-comment);
    font-style: italic;
}

/* Clickable table rows */
.results-table tbody tr {
    cursor: pointer;
}

.results-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Add padding to container for time bar */
body {
    padding-bottom: 28px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .log-detail-panel {
        width: 100%;
        right: -100%;
    }

    .pagination-controls {
        flex-wrap: wrap;
    }
}

/* ============================
   Query Reference View
   ============================ */

/* Query Reference - Layout */
#queryReferenceTabContent,
#referenceView {
    height: calc(100vh - 100px);
}

.reference-view-section {
    padding: 0;
    max-width: 100%;
    margin: 0;
    height: 100%;
    overflow: hidden;
}

.reference-content {
    height: 100%;
}

.ref-layout {
    display: flex;
    height: 100%;
}

.ref-sidebar {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 12px 0;
    overflow-y: auto;
}

.ref-sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ref-sidebar-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 4px 14px 6px;
}

.ref-sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 12px;
}

.ref-cat-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s, color 0.1s;
    border-left: 2px solid transparent;
}

.ref-cat-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ref-cat-btn.active {
    color: var(--accent-primary);
    background: var(--bg-tertiary);
    border-left-color: var(--accent-primary);
}

.ref-cat-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}

.ref-cat-btn.active .ref-cat-count {
    background: var(--accent-glow);
    color: var(--accent-primary);
}

/* Main content area */
.ref-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.ref-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.ref-search-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 7px 12px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-family: var(--font-main);
    transition: border-color 0.15s;
}

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

.ref-result-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Function list */
.ref-function-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 24px;
}

.ref-cat-group {
    margin-bottom: 8px;
}

.ref-cat-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 0 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.ref-cat-header-count {
    font-size: 0.65rem;
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 6px;
}

/* Compact function item */
.ref-item {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    margin-bottom: 4px;
    background: var(--bg-secondary);
    transition: border-color 0.15s;
}

.ref-item:hover {
    border-color: var(--border-hover, var(--text-muted));
}

.ref-item.expanded {
    border-color: var(--accent-primary);
}

.ref-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    cursor: pointer;
    gap: 8px;
    user-select: none;
}

.ref-item-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.ref-item-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.ref-op-name {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 3px;
}

.ref-item-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.ref-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.15s;
}

.ref-item.expanded .ref-chevron {
    transform: rotate(90deg);
}

/* Expanded detail */
.ref-item-detail {
    padding: 0 10px 10px;
    border-top: 1px solid var(--border-color);
}

.ref-detail-syntax {
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.ref-detail-syntax code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--syntax-function);
}

.ref-detail-params {
    margin-bottom: 8px;
}

.ref-param-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.78rem;
}

.ref-param-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.ref-param-row code {
    font-family: var(--font-mono);
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.78rem;
}

.ref-param-type {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-family: var(--font-mono);
}

.ref-param-req {
    background: var(--error, #ef4444);
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.ref-param-opt {
    background: var(--text-muted);
    color: var(--bg-primary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.ref-param-desc {
    flex: 1 1 100%;
    color: var(--text-muted);
    font-size: 0.73rem;
    margin-top: 2px;
}

.ref-detail-examples {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ref-example {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 8px;
    transition: border-color 0.15s;
}

.ref-example:hover {
    border-color: var(--accent-primary);
}

.ref-example code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ref-copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 3px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.ref-copy-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

/* Responsive */
@media (max-width: 768px) {
    .ref-sidebar {
        display: none;
    }
}

/* ============================
   Authentication & User UI
   ============================ */

/* Login Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-header h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Login modal specific styles */
#loginModal .modal-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: none;
    padding: 2rem 1.25rem 1rem;
}

#loginModal .modal-header h2 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

/* New large login logo styles */
.login-logo-large {
    width: 200px;
    height: 200px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 25px var(--accent-glow));
    transition: filter 0.3s ease;
}

.login-logo-large:hover {
    filter: drop-shadow(0 0 30px var(--accent-glow));
}

.login-title {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.1rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    opacity: 0.5;
    letter-spacing: 2px;
    text-transform: none;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.625rem;
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 0.875rem;
    box-sizing: border-box;
}

.form-group textarea {
    resize: none;
    min-height: 4rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.error-message {
    color: var(--error);
    font-size: 0.8125rem;
    margin-top: 0.5rem;
    min-height: 1.25rem;
}

.form-actions {
    margin-top: 1.5rem;
}

/* User Display in Header */
.user-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Gravatar */
.gravatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.comments-panel .gravatar {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
}

/* Auth Required Elements (hidden by default) */
.auth-required {
    display: none;
}

/* ============================
   Navigation Tabs (inline header)
   ============================ */

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex-shrink: 0;
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 0.625rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font-main);
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--overlay-subtle);
}

.nav-tab.active {
    color: var(--accent-secondary);
    background: var(--accent-glow);
}

.badge {
    background: var(--accent-tertiary);
    color: white;
    padding: 0.0625rem 0.375rem;
    border-radius: 10px;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.4;
}

/* ============================
   Comments Section
   ============================ */

.comments-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.comments-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.comments-header h4 {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.comment-count {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Comments List */
.comments-list {
    margin-bottom: 1rem;
}

.no-comments {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    padding: 1.5rem;
}

.comment-item {
    background: var(--bg-tertiary);
    padding: 0.5rem 0.625rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 2px solid var(--accent-primary);
}

.comment-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.comment-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    flex: 1;
}

.comment-author {
    font-weight: 600;
    color: var(--accent-primary);
}

.comment-date {
    color: var(--text-muted);
}

.comment-edited {
    color: var(--text-muted);
    font-style: italic;
}

.comment-body {
    margin-left: 2rem;
}

.comment-tags-display {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.tag {
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-size: 0.625rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.tag-important {
    background: var(--accent-tertiary);
    color: white;
}

.tag-todo {
    background: #fbbf24;
    color: #1a1a2e;
}

.tag-resolved {
    background: #4ade80;
    color: white;
}

.comment-text {
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.comment-actions {
    margin-top: 0.375rem;
    margin-left: 2rem;
    display: flex;
    gap: 0.5rem;
}

.btn-edit-comment,
.btn-delete-comment {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit-comment:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-delete-comment:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Comment Input Area */
.comment-input-area {
    margin-top: 1rem;
}

.comment-textarea {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 0.8rem;
    resize: none;
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.comment-tags,
.comment-tags-edit {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
}

.comment-tags label,
.comment-tags-edit label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.comment-tags input[type="checkbox"],
.comment-tags-edit input[type="checkbox"] {
    cursor: pointer;
}

/* Comment Edit Mode */
.comment-edit-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 0.8125rem;
    resize: none;
    margin-bottom: 0.5rem;
    min-height: 80px;
}

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

.comment-edit-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-save-edit,
.btn-cancel-edit {
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-save-edit {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.btn-save-edit:hover {
    background: var(--accent-secondary);
}

.btn-cancel-edit {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-cancel-edit:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* ============================
   Comments Sub-Tabs
   ============================ */

.comments-sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    padding: 0;
}

.comments-sub-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    font-family: var(--font-main);
}

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

.comments-sub-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* ============================
   Comment Graph View
   ============================ */

.comment-graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px 6px 0 0;
    border: 1px solid var(--border-color);
    border-bottom: none;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.comment-graph-field-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-graph-field-selector label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.comment-graph-dropdown {
    position: relative;
}

.comment-graph-dropdown-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: var(--font-main);
    min-width: 140px;
    text-align: left;
}

.comment-graph-dropdown-btn:hover,
.comment-graph-dropdown-btn:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.comment-graph-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    max-height: 250px;
    overflow-y: auto;
    min-width: 200px;
    padding: 4px 0;
}

.comment-graph-dropdown-menu label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
}

.comment-graph-dropdown-menu label:hover {
    background: var(--bg-hover);
}

.comment-graph-dropdown-menu input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-primary);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.comment-graph-dropdown-menu input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.comment-graph-dropdown-menu input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3.5px;
    top: 1px;
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.comment-graph-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-graph-filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-graph-min-input {
    width: 48px;
    padding: 3px 6px;
    font-size: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    appearance: textfield;
    -moz-appearance: textfield;
}

.comment-graph-min-input::-webkit-inner-spin-button,
.comment-graph-min-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

.comment-graph-stats {
    padding: 4px 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.comment-graph-canvas {
    width: 100%;
    flex: 1;
    min-height: 300px;
    border: 1px solid var(--border-color);
    border-radius: 0 0 6px 6px;
    position: relative;
    background: var(--bg-primary);
}

#commentsGraphView {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
}

.comment-graph-detail {
    position: absolute;
    top: 60px;
    right: 12px;
    width: 340px;
    max-height: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.comment-graph-detail-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comment-graph-detail-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.comment-graph-detail-close:hover {
    color: var(--text-primary);
}

.comment-graph-detail-body {
    padding: 10px 12px;
    overflow-y: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex: 1;
}

.comment-graph-detail-body .detail-field {
    margin-bottom: 6px;
}

.comment-graph-detail-body .detail-field-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.comment-graph-detail-body .detail-field-value {
    color: var(--text-primary);
    word-break: break-all;
}

.comment-graph-detail-body .detail-comment {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.comment-graph-detail-body .detail-comment:last-child {
    border-bottom: none;
}

.comment-graph-detail-body .detail-comment-author {
    font-weight: 500;
    color: var(--accent-primary);
    font-size: 0.7rem;
}

.comment-graph-detail-body .detail-comment-text {
    margin-top: 2px;
    line-height: 1.4;
}

.comment-graph-detail-body .detail-comment-tags {
    margin-top: 3px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.comment-graph-detail-body .detail-comment-tag {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
}

.comment-graph-detail-body .detail-view-log-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 0.7rem;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-main);
}

.comment-graph-detail-body .detail-view-log-btn:hover {
    opacity: 0.85;
}

.comment-graph-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================
   Commented Logs View
   ============================ */

#commentedView {
    display: none;
}

.commented-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.commented-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#commentedResults {
    margin-top: 1rem;
}

.comment-author-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.gravatar-sm {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.comment-text-cell {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.comment-log-cell code {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.comment-date-cell {
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.comment-tags-cell {
    white-space: nowrap;
}

.commented-selected-count {
    font-size: 0.8rem;
    color: var(--accent-primary);
    font-weight: 500;
    white-space: nowrap;
}

.alerts-table th input[type="checkbox"],
.alerts-table td input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-primary);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    vertical-align: middle;
    transition: background 0.15s, border-color 0.15s;
}

.alerts-table th input[type="checkbox"]:hover,
.alerts-table td input[type="checkbox"]:hover {
    border-color: var(--accent-primary);
}

.alerts-table th input[type="checkbox"]:checked,
.alerts-table td input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.alerts-table th input[type="checkbox"]:checked::after,
.alerts-table td input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

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

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-message {
    font-size: 0.875rem;
    text-align: center;
}

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

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.5rem 1rem 1rem;
    min-width: 300px;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(100%);
    opacity: 0;
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    word-wrap: break-word;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--text-primary); /* Ensure good contrast */
    opacity: 0.9;
    word-wrap: break-word;
    line-height: 1.4;
}

.toast-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: var(--transition);
    line-height: 1;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Toast Types */
.toast-success {
    border-left: 4px solid var(--success);
    background: rgba(74, 222, 128, 0.1) !important;
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-success .toast-title {
    color: var(--success);
    font-weight: 600; /* Ensure good visibility */
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-error .toast-icon {
    color: var(--error);
}

.toast-error .toast-title {
    color: var(--error);
    font-weight: 600; /* Ensure good visibility */
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-warning .toast-title {
    color: var(--warning);
    font-weight: 600; /* Ensure good visibility */
}

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

.toast-info .toast-icon {
    color: var(--info);
}

.toast-info .toast-title {
    color: var(--info);
    font-weight: 600; /* Ensure good visibility */
}

/* Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    transition: width linear;
    border-radius: 0 0 8px 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }
}

/* ============================
   Utility Classes
   ============================ */

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font-main);
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

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

.no-data {
    color: var(--text-muted);
    font-style: italic;
}

/* ============================
   User Management
   ============================ */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Fractal Management Pagination */
.fractals-pagination-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.fractals-pagination-info {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.users-list {
    margin-top: 1rem;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th {
    text-align: left;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.users-table td {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.users-table tr[ondblclick]:hover {
    background: var(--hover-bg);
}

.edit-user-input {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100%;
    max-width: 200px;
}

.edit-user-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

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

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

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.role-admin {
    background: rgba(156, 106, 222, 0.2);
    color: var(--accent-primary);
}

.role-analyst {
    background: rgba(96, 165, 250, 0.2);
    color: var(--info);
}

.role-user {
    background: rgba(96, 165, 250, 0.2);
    color: var(--info);
}

.role-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.user-actions-cell {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-invite-reset {
    background: transparent;
    border: 1px solid rgba(156, 106, 222, 0.3);
    color: var(--accent-primary);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-invite-reset:hover {
    border-color: var(--accent-primary);
    background: rgba(156, 106, 222, 0.1);
}

.invite-link-banner {
    background: rgba(156, 106, 222, 0.08);
    border: 1px solid rgba(156, 106, 222, 0.25);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    display: none;
}

.invite-link-content {
    padding-right: 2rem;
}

.invite-link-header {
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.invite-link-note {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
}

.invite-link-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.invite-link-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.invite-link-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

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

.btn-edit-user {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit-user:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-delete-user {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-delete-user:hover {
    border-color: var(--error);
    color: var(--error);
}

.add-user-form {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.add-user-form h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.role-select {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.625rem;
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 0.875rem;
}

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

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font-main);
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-ghost {
    background: none;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    font-family: var(--font-main);
    font-weight: 500;
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-main);
    font-weight: 500;
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.25);
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.75rem;
}

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

.form-hint code {
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    color: var(--accent-secondary);
}

.form-error {
    color: #ff6b6b;
    font-size: 0.83rem;
    margin-top: 8px;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-only {
    display: none;
}

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

/* ============================
   Comments Panel Specific
   ============================ */

.add-comment-form {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.625rem;
    margin-bottom: 0.75rem;
}

.btn-add-comment {
    width: 100%;
    margin-top: 0.5rem;
}

.comments-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0 -0.75rem 0.75rem;
}

.empty-comments {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    text-align: center;
}

.empty-comments .empty-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.empty-comments .empty-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.comments-panel .comments-list {
    margin: 0;
}

.comments-panel .comment-item {
    margin-bottom: 0.5rem;
}

.comments-panel .comment-item:last-child {
    margin-bottom: 0;
}

/* Tag input for comment creation */
.comment-tags-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.5rem;
    min-height: 2rem;
}

.comment-tags-input:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.comment-tag-field {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.75rem;
    outline: none;
    flex: 1;
    min-width: 60px;
    padding: 0.125rem 0;
}

.comment-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.125rem 0.375rem;
    font-size: 0.6875rem;
    white-space: nowrap;
}

.comment-tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.875rem;
    line-height: 1;
}

.comment-tag-remove:hover {
    opacity: 1;
}

/* Tag suggestions dropdown */
.comment-tags-input {
    position: relative;
}

.tag-suggestions-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
    margin-bottom: 2px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

.tag-suggestion-item {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle, var(--border-color));
}

.tag-suggestion-item:last-child {
    border-bottom: none;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
    background: var(--accent-glow);
    color: var(--accent-primary);
}

/* Tag badges on rendered comments */
.comment-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.25rem 0 0.375rem;
}

.comment-tag-badge {
    display: inline-block;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.0625rem 0.375rem;
    font-size: 0.6875rem;
}

/* Generate notebook tag selector pills */
.generate-nb-tag {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.25rem 0.625rem;
    font-size: 0.8rem;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.15s ease;
}

.generate-nb-tag:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.generate-nb-tag.selected {
    background: var(--accent-glow);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Stored query link on comments */
.comment-query {
    margin-top: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 3px;
    font-size: 0.6875rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-query-label {
    opacity: 0.6;
}

.comment-query-link {
    color: var(--accent-primary);
    cursor: pointer;
    font-family: var(--font-mono, monospace);
}

.comment-query-link:hover {
    text-decoration: underline;
}

/* ============================
   Time Bar Status Indicator
   ============================ */

.status-indicator-compact {
    display: inline-flex;
    align-items: center;
}

/* ============================
   User Display & Menu Dropdown
   ============================ */

.user-clickable {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    transition: var(--transition);
}

.user-clickable:hover {
    background: var(--bg-hover);
}

.user-display {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.375rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.user-menu-dropdown.open {
    display: block;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.8125rem;
    border-radius: 5px;
    cursor: pointer;
    transition: var(--transition);
}

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

.user-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.user-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.user-menu-item.logout-item:hover {
    color: var(--error);
}

/* Theme transition */
body.theme-transitioning,
body.theme-transitioning * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

.btn-logout {
    margin-left: 0.5rem;
}

/* ============================
   Performance View
   ============================ */

.performance-view-section {
    max-width: 100%;
    margin: 0;
}

.performance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.performance-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin: 0;
}

.performance-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.perf-refresh-select {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Metric Cards Grid */
.perf-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.perf-metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    text-align: center;
    transition: var(--transition);
}

.perf-metric-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
}

.perf-metric-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.375rem;
}

.perf-metric-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* Charts Row */
.perf-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.perf-chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem 1rem 1.5rem;
    height: 320px;
    position: relative;
    overflow: hidden;
}

.perf-chart-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    z-index: 1;
}

.perf-chart-card h3 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.5rem 0;
}

/* Sections */
.perf-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.perf-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.perf-section-header h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.perf-count {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--accent-glow);
    color: var(--accent-secondary);
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Performance Table */
.perf-table-container {
    max-height: 400px;
    overflow-y: auto;
}

.perf-table {
    font-size: 0.75rem;
}

.perf-table th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    z-index: 1;
}

.perf-elapsed {
    font-family: var(--font-mono);
    font-weight: 600;
    white-space: nowrap;
}

.perf-time {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.perf-query-cell {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

/* Warning/Danger rows */
tr.perf-warning td {
    color: var(--warning);
}

tr.perf-danger td {
    color: var(--error);
}

/* Status indicators */
.perf-status-ok {
    color: var(--success);
    font-weight: 500;
    font-size: 0.6875rem;
}

.perf-status-error {
    color: var(--error);
    font-weight: 500;
    font-size: 0.6875rem;
}

/* Kill button */
.btn-kill-query {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 3px;
    color: var(--error);
    font-size: 0.6875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-kill-query:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--error);
}

/* Responsive */
@media (max-width: 768px) {
    .perf-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .perf-charts-row {
        grid-template-columns: 1fr;
    }
}

/* ============================
   Settings View
   ============================ */

.settings-view-section {
    max-width: 100%;
    margin: 0;
}

.settings-view-section > h2 {
    font-size: 1.75rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.settings-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-card h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.settings-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-ok {
    color: var(--success);
}

.status-error {
    color: var(--error);
}

.danger-section h4 {
    color: var(--error);
}

/* Prism Members Table */
.prism-members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.prism-members-table thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-color);
}

.prism-members-table thead th:last-child {
    width: 2.5rem;
}

.prism-members-table tbody td {
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.prism-members-table tbody tr:last-child td {
    border-bottom: none;
}

.prism-members-table tbody tr:hover {
    background: var(--bg-secondary);
}

.prism-members-actions {
    text-align: right;
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.btn-icon.btn-delete:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Fractal Management Button Improvements */
.edit-fractal-btn,
.delete-fractal-btn {
    font-size: 0.8125rem;
    font-weight: 500;
    min-width: 60px;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.edit-fractal-btn {
    background: rgba(156, 106, 222, 0.1);
    border: 1px solid rgba(156, 106, 222, 0.3);
    color: var(--accent-primary);
}

.edit-fractal-btn:hover {
    background: rgba(156, 106, 222, 0.2);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.delete-fractal-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.delete-fractal-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
    transform: translateY(-1px);
}

/* Real-time Status Updates */
.update-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--success);
    font-size: 0.7rem;
    animation: pulse-indicator 1.5s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.count-increase {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--success);
    font-weight: bold;
    font-size: 1rem;
    animation: bounce-up 0.6s ease-out;
}

@keyframes bounce-up {
    0% { transform: translateY(0) scale(1); opacity: 0.7; }
    50% { transform: translateY(-3px) scale(1.1); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.status-updated {
    transition: all 0.3s ease;
}

.highlight-update {
    background: rgba(77, 222, 128, 0.1) !important;
    border: 1px solid rgba(77, 222, 128, 0.3) !important;
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(77, 222, 128, 0.2) !important;
}

.live-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.125rem 0.375rem;
    background: rgba(77, 222, 128, 0.2);
    border: 1px solid var(--success);
    border-radius: 3px;
    color: var(--success);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* ============================
   Alert Management System
   ============================ */

/* Alert View Container */
.alerts-view-section {
    max-width: 100%;
    margin: 0;
    padding: 1rem;
}

.alerts-view-section > h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

/* Alert Header Controls */
.alerts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.alerts-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Alert Filters */
.alerts-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.alerts-search {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.alerts-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.alerts-filter-select {
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Alert Cards */
.alerts-list {
    display: grid;
    gap: 1rem;
}

.alert-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    transition: var(--transition);
    position: relative;
}

.alert-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.alert-card.enabled {
    border-left: 4px solid var(--success);
}

.alert-card.disabled {
    border-left: 4px solid var(--text-muted);
    opacity: 0.7;
}

/* Alert Card Header */
.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.alert-title h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.alert-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.alert-status.status-enabled {
    background: rgba(77, 222, 128, 0.15);
    color: var(--success);
    border: 1px solid rgba(77, 222, 128, 0.3);
}

.alert-status.status-disabled {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(156, 163, 175, 0.3);
}

/* Alert Actions */
.alert-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.375rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-icon.btn-danger:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Alert Content */
.alert-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.alert-query {
    margin-bottom: 1rem;
}

.alert-query strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.alert-query code {
    display: block;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    font-family: var(--font-code);
    font-size: 0.8125rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.4;
}

/* Alert Labels */
.alert-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.label {
    background: var(--accent-tertiary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.alert-labels-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* Alert References */
.alert-references {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.alert-references li {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.alert-reference-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    word-break: break-all;
    opacity: 0.8;
}

.alert-reference-link:hover {
    color: var(--accent-primary);
    text-decoration: underline;
    opacity: 1;
}

/* Alert Metadata */
.alert-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.alert-meta-item {
    font-size: 0.8125rem;
}

.alert-meta-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.25rem;
}

/* Alert Modals */
.modal-content.large {
    max-width: 800px;
    width: 95vw;
}

.modal-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* YAML Input */
.yaml-input {
    width: 100%;
    height: 400px;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-code);
    font-size: 0.8125rem;
    line-height: 1.5;
    resize: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.yaml-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Alert Form Specific */
.webhooks-checkboxes {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
}

.webhook-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.webhook-checkbox:hover {
    background: var(--bg-hover);
}

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

.webhook-url {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-family: var(--font-code);
}

/* Action Tabs */
.actions-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.action-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font-main);
    transition: var(--transition);
}

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

.action-tab.active {
    border-bottom-color: var(--accent-primary);
    color: var(--text-primary);
    font-weight: 500;
}

.action-tab-content {
    display: none;
}

.action-tab-content.active {
    display: block;
}

.actions-checkboxes {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
}

.selected-actions-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.selected-action-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
}

.selected-action-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-action-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

.selected-action-remove:hover {
    color: var(--danger-color, #e74c3c);
}

/* Actions Manage View */
.actions-manage-section {
    padding: 1.5rem;
    max-width: min(1400px, 90vw);
}

.actions-manage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.actions-manage-header .header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.actions-manage-header .header-left h2 {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.actions-manage-header .header-right {
    display: flex;
    gap: 0.5rem;
}

/* Inline create/edit panels */
.actions-create-panel,
.actions-edit-panel {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.actions-create-panel {
    border: 1px solid var(--border-color);
}

.actions-edit-panel {
    border: 1px solid var(--accent-primary);
}

.actions-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.actions-panel-header h3 {
    color: var(--text-primary);
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.actions-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.actions-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.actions-form-group.full-width {
    grid-column: 1 / -1;
}

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

.actions-form-group input,
.actions-form-group select,
.actions-form-group textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
}

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

.actions-form-group .form-help {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.actions-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.actions-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.field-mappings-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.field-mapping-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-mapping-row input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    color: var(--text-primary);
    font-size: 0.85rem;
}

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

.field-mapping-row .mapping-arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.field-mapping-row .mapping-remove {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0.2rem 0.4rem;
}

.field-mapping-row .mapping-remove:hover {
    color: var(--danger);
}

@media (max-width: 768px) {
    .actions-manage-header {
        flex-direction: column;
        align-items: stretch;
    }

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

/* Webhook Management */
.webhooks-filters,
.fractal-actions-filters,
.dict-actions-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.webhooks-filters input,
.webhooks-filters select,
.fractal-actions-filters input,
.fractal-actions-filters select,
.dict-actions-filters input,
.dict-actions-filters select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.webhooks-filters input:focus,
.fractal-actions-filters input:focus,
.dict-actions-filters input:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.webhooks-list,
.fractal-actions-list,
.dict-actions-list {
    display: grid;
    gap: 1rem;
}

.webhook-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    transition: var(--transition);
}

.webhook-card:hover {
    border-color: var(--accent-primary);
}

.webhook-card.enabled {
    border-left: 3px solid var(--success);
}

.webhook-card.disabled {
    border-left: 3px solid var(--text-muted);
    opacity: 0.7;
}

.webhook-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.webhook-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.webhook-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.webhook-details {
    display: grid;
    gap: 0.375rem;
    font-size: 0.8125rem;
}

.webhook-details strong {
    color: var(--text-primary);
}

/* Authentication Configuration */
.auth-config {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 0.5rem;
}

/* Custom Headers */
.header-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.header-name,
.header-value {
    flex: 1;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8125rem;
}

.header-name:focus,
.header-value:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state .empty-text {
    font-size: 1.125rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.empty-state .empty-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Alert Count Badge */
#alertsCountBadge {
    background: var(--accent-primary);
    color: white;
    border-radius: 10px;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    min-width: 1.25rem;
    text-align: center;
}

/* Loading States */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.5rem;
    flex-direction: column;
}

.loading-spinner .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(65, 105, 225, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.cancel-query-btn {
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cancel-query-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: var(--hover-bg);
}

.alerts-list .loading,
.webhooks-list .loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Error States */
.alerts-list .error,
.webhooks-list .error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 1rem;
    color: var(--error);
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .alerts-header {
        flex-direction: column;
        align-items: stretch;
    }

    .alerts-controls {
        justify-content: stretch;
    }

    .alerts-controls button {
        flex: 1;
    }

    .alerts-filters {
        flex-direction: column;
        gap: 0.75rem;
    }

    .alerts-search {
        max-width: none;
    }

    .alert-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .alert-actions {
        align-self: flex-end;
    }

    .alert-meta {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .webhook-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .webhook-actions {
        align-self: flex-end;
    }

    .header-row {
        flex-direction: column;
    }

    .modal-content.large {
        width: 95vw;
        max-width: none;
        margin: 1rem;
    }
}

/* Alert Panel - Right Side Sliding Panel */
.alert-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    overflow-y: auto;
    transition: right 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.alert-panel.open {
    right: 0;
}

.alert-panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.alert-panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 2rem 0.5rem 0;
}

.alert-panel-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.alert-panel-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: var(--transition);
}

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

.alert-panel-content {
    padding: 1.5rem;
}

.alert-form-group {
    margin-bottom: 1.5rem;
}

.alert-form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.alert-name-template-hint {
    display: inline-flex;
    align-items: center;
    margin-left: 0.375rem;
    color: var(--text-muted);
    cursor: help;
    position: relative;
    vertical-align: middle;
}

.alert-name-template-hint:hover {
    color: var(--accent-secondary);
}

.alert-name-template-hint:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 8px);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.alert-form-input,
.alert-form-select,
.alert-form-textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.alert-form-input:focus,
.alert-form-select:focus,
.alert-form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.alert-form-textarea {
    resize: none;
    min-height: 80px;
}

.alert-checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-checkbox {
    width: auto;
}

.alert-checkbox-label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

/* Alert type toggle */
.alert-type-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.alert-type-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

/* Window duration input */
.window-duration-input {
    display: flex;
    gap: 0.5rem;
}

.window-duration-input .alert-form-input:first-child {
    flex: 1;
    -moz-appearance: textfield;
}

.window-duration-input .alert-form-input:first-child::-webkit-inner-spin-button,
.window-duration-input .alert-form-input:first-child::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.window-duration-input .alert-form-input:last-child {
    width: 120px;
    flex-shrink: 0;
}

/* Window badge in alert table */
.alert-window-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    margin-left: 0.25rem;
    vertical-align: middle;
}

.alert-panel-actions {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
}

.alert-panel-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.alert-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.alert-btn-primary {
    background: var(--accent-primary);
    color: white;
}

.alert-btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

/* Main content adjustment when panel is open */
.main-content.panel-open {
    margin-right: 400px;
    transition: margin-right 0.3s ease;
}

/* Alert Editor Header Styles */
.alert-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.alert-editor-header .header-right {
    margin-left: auto;
}

/* Responsive adjustments for alert panel */
@media (max-width: 768px) {
    .alert-panel {
        width: 100vw;
        right: -100vw;
    }

    .alert-panel.open {
        right: 0;
    }

    .main-content.panel-open {
        margin-right: 0;
    }
}

/* Alerts Table Layout */
.alerts-table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.alerts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.alerts-table thead {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.alerts-table th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alerts-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.alerts-table tbody tr:last-child {
    border-bottom: none;
}

.alert-row {
    cursor: pointer;
    transition: var(--transition);
}

.alert-row:hover {
    background: var(--bg-hover);
}

.alert-row.disabled {
    opacity: 0.6;
}

.alerts-table td {
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.alert-name strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.alert-description-preview {
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.2;
    margin-left: calc(8px + 0.5rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.alert-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.status-dot.status-enabled {
    background: var(--success);
    box-shadow: 0 0 4px rgba(74, 222, 128, 0.4);
}

.status-dot.status-disabled {
    background: var(--text-muted);
}

.status-dot.status-auto-disabled {
    background: #f59e0b;
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
}

.alert-row.auto-disabled {
    opacity: 0.75;
}

.alert-auto-disabled-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    margin-left: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.alert-auto-disabled-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #f59e0b;
    font-size: 0.85rem;
}

.alert-auto-disabled-banner svg {
    flex-shrink: 0;
}

.system-pressure-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--warning);
    font-size: 0.82rem;
    animation: pressureBannerIn 0.2s ease-out;
}

.system-pressure-banner svg {
    flex-shrink: 0;
}

@keyframes pressureBannerIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.status-badge.status-auto-disabled {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.alert-run-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.alert-run-time-slow {
    color: var(--warning-color, #f59e0b);
}

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

/* Alert Details Panel */
.alert-details-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.alert-details-panel.open {
    right: 0;
}

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

.alert-details-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alert-details-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.alert-details-section {
    margin-bottom: 2rem;
}

.alert-detail-field {
    margin-bottom: 1rem;
}

.alert-detail-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.alert-detail-field p,
.alert-detail-field span {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.alert-query-display {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

.alert-query-display code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.alert-details-actions {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-details-actions button {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.alert-details-actions .btn-primary {
    background: var(--accent-primary);
    color: white;
}

.alert-details-actions .btn-primary:hover {
    background: var(--accent-secondary);
}

.alert-details-actions .btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.alert-details-actions .btn-secondary:hover {
    background: var(--bg-tertiary);
}

.alert-details-actions .btn-danger {
    background: var(--error);
    color: white;
}

.alert-details-actions .btn-danger:hover {
    background: #dc2626;
}

/* Responsive adjustments for alerts table */
@media (max-width: 768px) {
    .alert-details-panel {
        width: 100vw;
        right: -100vw;
    }

    .alert-details-panel.open {
        right: 0;
    }

    .alerts-table th,
    .alerts-table td {
        padding: 0.5rem;
    }

    .alert-name strong {
        font-size: 0.9rem;
    }

    .alert-description-preview {
        font-size: 0.75rem;
    }

    .alerts-table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .alerts-pagination {
        flex-wrap: wrap;
        gap: 0.125rem;
    }

    .pagination-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

/* Alerts Table Header */
.alerts-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

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

.alerts-page-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alerts-page-size label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.alerts-page-size select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    min-width: 60px;
}

/* Alerts Pagination */
.alerts-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.pagination-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    font-weight: 600;
}

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

.pagination-ellipsis {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================
   Fractal Listing View (Main Page)
   ============================ */

#fractalListingTabContent {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
}

#fractalListingTabContent > .results-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#fractalListingContainer {
    flex: 1;
    overflow-y: auto;
}

.fractal-listing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.fractal-listing-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.fractal-listing-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.fractal-listing-search {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    min-width: 250px;
}

.fractal-listing-search:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-icon-small {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
}

.btn-icon-small:hover {
    background: var(--bg-hover);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.fractal-listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.fractal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.fractal-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-2px);
}

.fractal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.fractal-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.fractal-card-actions {
    display: flex;
    gap: 0.5rem;
}

.fractal-card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.fractal-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.fractal-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fractal-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fractal-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.fractal-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.fractal-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.fractal-card-arrow {
    font-size: 1.5rem;
    color: var(--accent-primary);
    transition: transform 0.2s ease;
}

.fractal-card:hover .fractal-card-arrow {
    transform: translateX(4px);
}

.fractal-listing-pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-btn-compact {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
    padding: 0;
}

.page-btn-compact:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.page-btn-compact:disabled {
    opacity: 0.3;
    cursor: default;
}

.page-info-compact {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Fractal Listing Table - matches notebooks/dashboards style */
.fractal-listing-table {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.fractal-listing-table table {
    width: 100%;
    border-collapse: collapse;
}

.fractal-listing-table thead {
    background: var(--bg-tertiary);
}

.fractal-listing-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.fractal-listing-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.fractal-listing-table tbody tr:last-child {
    border-bottom: none;
}

.fractal-listing-table tbody tr:hover {
    background: var(--bg-hover);
}

.fractal-listing-table td {
    padding: 12px 15px;
    font-size: 0.9rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.fractal-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9375rem;
}

.fractal-size {
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.create-type-toggle {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px;
    gap: 2px;
}

.type-toggle-btn {
    flex: 1;
    padding: 6px 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.type-toggle-btn.active {
    background: var(--accent-primary);
    color: #fff;
    font-weight: 500;
}

.type-toggle-btn:hover:not(.active) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.prism-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(156, 106, 222, 0.18);
    color: var(--accent-secondary);
    border: 1px solid rgba(156, 106, 222, 0.3);
    vertical-align: middle;
    margin-left: 6px;
    text-transform: uppercase;
}

.fractal-latest {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.fractal-latest.recent {
    color: var(--success);
}

.fractal-latest.old {
    color: var(--warning);
}

.fractal-latest.very-old {
    color: var(--text-muted);
}

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

    .fractal-listing-controls {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .fractal-listing-search {
        min-width: 100%;
    }

    .fractal-listing-table th,
    .fractal-listing-table td {
        padding: 0.75rem 1rem;
    }

    .fractal-listing-table th {
        font-size: 0.8125rem;
    }

    .fractal-listing-table td {
        font-size: 0.8125rem;
    }

    .fractal-name {
        font-size: 0.875rem;
    }
}


/* Chart Container Styles */
.chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
    min-height: 400px;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 400px;
}

.chart-container h3 {
    color: var(--text-primary);
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

/* Network Graph Styles */
.chart-container #networkGraph {
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--bg-tertiary);
    overflow: visible;
    position: relative;
    touch-action: auto;
    min-width: 600px;
    min-height: 400px;
    width: 100%;
}

.chart-container #networkGraph .vis-network {
    background: var(--bg-primary) !important;
    pointer-events: auto;
    touch-action: auto;
}

.chart-container #networkGraph canvas {
    background: var(--bg-primary) !important;
    touch-action: auto;
}

/* Graph Toolbar */
.graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px 6px 0 0;
    border: 1px solid var(--bg-tertiary);
    border-bottom: none;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-main);
    flex-shrink: 0;
}

.graph-toolbar + #networkGraph {
    border-radius: 0 0 6px 6px;
}

.graph-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.graph-stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.graph-stat-count {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.graph-stat-separator {
    width: 1px;
    height: 12px;
    background: var(--border-color);
}

.graph-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.graph-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

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

.graph-legend-parent {
    background: var(--graph-node-parent);
}

.graph-legend-child {
    background: var(--graph-node-child);
}

.graph-search {
    flex: 0 1 160px;
}

.graph-search-input {
    width: 100%;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-family: var(--font-main);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
}

.graph-search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.graph-search-input::placeholder {
    color: var(--text-muted);
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.graph-toolbar-sep {
    width: 1px;
    height: 14px;
    background: var(--border-color);
    margin: 0 2px;
}

/* Graph Tooltips */
.graph-tooltip {
    font-family: var(--font-main);
    font-size: 0.75rem;
    max-width: 350px;
    line-height: 1.4;
}

.graph-tooltip-header {
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    word-break: break-all;
}

.graph-tooltip-row {
    display: flex;
    gap: 8px;
    padding: 1px 0;
}

.graph-tooltip-key {
    color: var(--text-muted);
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.65rem;
}

.graph-tooltip-key::after {
    content: ':';
}

.graph-tooltip-val {
    color: var(--text-primary);
    word-break: break-all;
}

.graph-tooltip-empty {
    color: var(--text-muted);
    font-style: italic;
}

div.vis-tooltip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    padding: 8px 10px !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-main) !important;
}

/* Graph Detail Panel */
.graph-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    border-radius: 0 8px 8px 0;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.graph-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.graph-detail-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.graph-detail-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    line-height: 1;
}

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

.graph-detail-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.graph-detail-id {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.graph-detail-id-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.graph-detail-id-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-primary);
    word-break: break-all;
    flex: 1;
}

.graph-detail-copy {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    display: flex;
    align-items: center;
}

.graph-detail-copy:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.graph-detail-role {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 3px;
    margin-bottom: 12px;
}

.graph-detail-role.parent {
    background: var(--graph-node-parent);
    color: #fff;
}

.graph-detail-role.child {
    background: var(--graph-node-child);
    color: #fff;
}

.graph-detail-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.graph-detail-field {
    padding: 6px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.graph-detail-field-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    font-family: var(--font-mono);
}

.graph-detail-field-value {
    font-size: 0.75rem;
    color: var(--text-primary);
    word-break: break-all;
}

.graph-detail-empty {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
    padding: 12px 0;
}

/* Graph Context Menu */
.graph-context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    min-width: 160px;
}

.graph-ctx-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-family: var(--font-main);
    color: var(--text-primary);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.graph-ctx-item:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.graph-ctx-item + .graph-ctx-item {
    border-top: 1px solid var(--border-color);
}

/* World Map Visualization */
.worldmap-container {
    position: relative;
    width: 100%;
    height: 500px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-primary);
}

.worldmap-container .leaflet-container {
    background: var(--bg-primary);
    font-family: var(--font-main);
}

.worldmap-container .leaflet-control-zoom a {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.worldmap-container .leaflet-control-zoom a:hover {
    background: var(--bg-hover);
}

.worldmap-container .leaflet-control-attribution {
    background: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
    font-size: 10px;
}

.worldmap-container .leaflet-control-attribution a {
    color: var(--accent-primary) !important;
}

.worldmap-container .leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    font-size: 12px;
}

.worldmap-container .leaflet-popup-tip {
    background: var(--bg-secondary);
}

.worldmap-container .leaflet-popup-close-button {
    color: var(--text-muted);
}

.worldmap-container .leaflet-popup-close-button:hover {
    color: var(--text-primary);
}

.worldmap-popup-label {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 2px;
}

.worldmap-popup-coords {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
}

.worldmap-cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 12px;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Override MarkerCluster default styles */
.worldmap-container .marker-cluster {
    background: none !important;
}

.worldmap-container .marker-cluster div {
    background: none !important;
}

/* Single Value Display */
.singleval-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    padding: 20px;
    box-sizing: border-box;
}

.singleval-value {
    font-size: 3rem;
    font-weight: 600;
    color: var(--accent-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.singleval-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Conditional Formatting Config Panel */
.row-coloring-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.row-coloring-overlay.open {
    opacity: 1;
}

.row-coloring-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 380px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.row-coloring-panel.open {
    right: 0;
}

.row-coloring-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.row-coloring-panel .panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.row-coloring-panel .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.row-coloring-panel .panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.row-coloring-rule {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 8px;
}

.rule-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rule-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.row-coloring-rule input[type="text"] {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    min-width: 0;
}

.row-coloring-rule select.rule-operator {
    padding: 6px 4px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    flex-shrink: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    min-width: 68px;
}

.rule-color-swatches {
    display: flex;
    gap: 4px;
    align-items: center;
}

.rule-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: border-color 0.15s, transform 0.15s;
}

.rule-swatch:hover {
    transform: scale(1.15);
}

.rule-swatch.active {
    border-color: var(--text-primary);
}

.rule-target-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.rule-target-btn {
    padding: 4px 10px;
    border: none;
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.rule-target-btn:first-child {
    border-right: 1px solid var(--border-color);
}

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

.row-coloring-rule .remove-rule-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 4px;
    flex-shrink: 0;
    line-height: 1;
}

.row-coloring-rule .remove-rule-btn:hover {
    color: var(--error);
}

.row-coloring-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 20px 0;
}

/* ================================================
   Notebook Styles
   ================================================ */

/* Notebook View Section */
.notebooks-view-section {
    padding: 20px;
    max-width: 100%;
    margin: 0;
}

/* Notebook Header */
.notebooks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.notebooks-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

/* Notebook Filters */
.notebooks-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.notebooks-search {
    flex: 1;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.notebooks-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Notebook Table */
.notebooks-table-container {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.notebooks-table {
    width: 100%;
    border-collapse: collapse;
}

.notebooks-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.notebooks-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.notebooks-table tbody tr {
    transition: var(--transition);
}

.notebooks-table tbody tr:hover {
    background: var(--bg-hover);
}

.notebooks-table tbody tr:last-child td {
    border-bottom: none;
}

/* Notebook Actions */
.notebook-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover {
    background: var(--accent-primary);
    color: white;
}

.btn-action.danger:hover {
    background: var(--error);
}

/* Notebook Pagination */
.notebooks-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

.notebooks-pagination span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Notebook Editor */
.notebook-editor {
    max-width: 100%;
    margin: 0;
    padding: 20px;
}

/* Notebook Header */
.notebook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.notebook-title-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notebook-title-area h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.notebook-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Notebook Presence */
.notebook-presence {
    display: flex;
    gap: 5px;
    align-items: center;
}

.presence-user {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border: 2px solid var(--bg-primary);
    position: relative;
}

.presence-user::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--success);
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
}

/* Variables Bar */
.variables-bar {
    margin-bottom: 0.75rem;
}

.variables-bar-empty {
    display: flex;
    align-items: center;
}

.variables-bar-items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.variable-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.variable-name {
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    white-space: nowrap;
    user-select: none;
}

.variable-value-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    width: 100px;
    outline: none;
    transition: border-color 0.15s ease;
}

.variable-value-input:focus {
    border-color: var(--accent-primary);
}

.variable-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 0.15rem;
    line-height: 1;
    transition: color 0.15s ease;
}

.variable-remove-btn:hover {
    color: var(--error);
}

.btn-add-variable {
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    transition: var(--transition);
}

.btn-add-variable:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Notebook Sections */
.notebook-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Section Container */
.notebook-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

.notebook-section:hover {
    box-shadow: var(--shadow-md);
}

.notebook-section.dragging {
    opacity: 0.7;
    transform: rotate(2deg);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.notebook-section .section-drag-handle {
    cursor: grab;
    user-select: none;
    color: var(--text-muted);
    padding: 0 4px;
    transition: var(--transition);
}

.notebook-section .section-drag-handle:hover {
    color: var(--accent-primary);
}

.notebook-section .section-drag-handle:active {
    cursor: grabbing;
}

.drop-indicator {
    pointer-events: none;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.section-type {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.section-type-icon {
    width: 16px;
    height: 16px;
}

.section-controls {
    display: flex;
    gap: 6px;
}

.section-control-btn {
    padding: 4px 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
}

.section-control-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

/* Section Content */
.section-content {
    padding: 2px 16px 12px;
}

/* Markdown Section */
.markdown-section .section-editor {
    display: flex;
    gap: 16px;
    min-height: 200px;
}

.markdown-editor,
.markdown-preview {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
}

.markdown-editor textarea {
    width: 100%;
    height: 200px;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

.markdown-preview {
    padding: 12px;
    overflow-y: auto;
    max-height: 400px;
}

.markdown-preview {
    line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    color: var(--text-primary);
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.markdown-preview h1 {
    font-size: 1.4rem;
    margin-top: 0;
}

.markdown-preview h2 {
    font-size: 1.2rem;
}

.markdown-preview h3 {
    font-size: 1.1rem;
}

.markdown-preview p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.markdown-preview br {
    line-height: 1.6;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 12px;
    padding-left: 20px;
    color: var(--text-secondary);
}

.markdown-preview li {
    margin-bottom: 4px;
}

.markdown-preview blockquote {
    border-left: 3px solid var(--accent-primary);
    margin: 12px 0;
    padding-left: 16px;
    color: var(--text-muted);
    font-style: italic;
}

.markdown-preview code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--syntax-string);
    border: 1px solid var(--border-color);
}

.markdown-preview pre {
    background: var(--bg-tertiary);
    padding: 14px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.markdown-preview pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.markdown-preview th,
.markdown-preview td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.markdown-preview th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-preview td {
    color: var(--text-secondary);
}

.markdown-preview hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

.markdown-preview a {
    color: var(--accent-primary);
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}

/* Query Section */
.query-section .query-editor {
    margin-bottom: 16px;
}

.query-section textarea {
    width: 100%;
    height: 120px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    outline: none;
}

.query-section textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.query-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.query-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.execute-query-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--accent-primary);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.execute-query-btn:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

.execute-query-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Comment Context Section */
.comment-context-section {
    padding: 0;
}

.comment-context-body {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-context-query {
    margin-bottom: 6px;
}

.comment-context-logid {
    margin-top: 4px;
}

.comment-context-logid-link {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 6px;
    cursor: pointer;
    transition: var(--transition);
}

.comment-context-logid-link:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.comment-context-search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.comment-context-search-icon:hover {
    color: var(--accent-primary);
}

/* Attack Chain Section Styles */
.attack-chain-section {
    padding: 0;
}

.attack-chain-executive {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.attack-chain-tactics {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.attack-chain-tactic {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.attack-chain-tactic > summary {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    list-style: none;
}

.attack-chain-tactic > summary::-webkit-details-marker {
    display: none;
}

.attack-chain-tactic > summary::before {
    content: '\25B6';
    font-size: 0.6rem;
    transition: transform 0.15s;
    color: var(--text-muted);
}

.attack-chain-tactic[open] > summary::before {
    transform: rotate(90deg);
}

.attack-chain-tactic > summary:hover {
    background: var(--bg-hover);
}

.attack-chain-tactic.empty > summary {
    color: var(--text-muted);
    font-weight: 400;
}

.attack-chain-badge {
    font-size: 0.7rem;
    background: var(--accent-primary);
    color: white;
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
    margin-left: auto;
}

.attack-chain-badge.empty {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.attack-chain-findings {
    list-style: none;
    padding: 6px 10px 6px 24px;
    margin: 0;
}

.attack-chain-finding {
    padding: 3px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    position: relative;
}

.attack-chain-finding::before {
    content: '\2022';
    position: absolute;
    left: -12px;
    color: var(--text-muted);
}

.attack-chain-link {
    color: var(--accent-primary);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.attack-chain-link:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

.attack-chain-no-findings {
    padding: 6px 10px 6px 24px;
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Inline Editor Styles */
.notebook-section.editing {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.inline-editor {
    padding: 0;
}

.inline-editor .editor-fields {
    margin-bottom: 12px;
}

.inline-editor .form-group {
    margin-bottom: 12px;
}

.inline-editor .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.inline-editor .form-group input,
.inline-editor .form-group textarea {
    font-family: inherit;
}

.inline-editor .form-group input:focus,
.inline-editor .form-group textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.inline-editor .markdown-preview {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.inline-editor .preview-content {
    min-height: 60px;
}

.editor-controls {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* Query Results */
.query-results {
    margin-top: 16px;
}

.query-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.query-results-header h4 {
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0;
}

.query-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.query-results-container {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    max-height: 400px;
    overflow: auto;
}

/* Add Section */
.add-section-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.btn-add-section {
    padding: 12px 24px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-add-section:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

/* Section Add Menu */
.add-section-menu {
    display: none;
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 150px;
}

.add-section-menu.show {
    display: block;
}

.add-section-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.add-section-option:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

/* Drag and Drop */
.section-drag-handle {
    cursor: grab;
    padding: 4px;
    color: var(--text-muted);
}

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

.section-drag-handle:hover {
    color: var(--accent-primary);
}

/* Loading States */
.notebook-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-muted);
}

.section-loading {
    display: flex;
    justify-content: center;
    padding: 20px;
    color: var(--text-muted);
}

/* Error States */
.notebook-error,
.section-error {
    padding: 12px;
    border-radius: 6px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    font-size: 0.9rem;
    margin: 12px 0;
}

/* Success States */
.notebook-success {
    padding: 12px;
    border-radius: 6px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
    font-size: 0.9rem;
    margin: 12px 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

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

.modal-content form {
    padding: 20px 24px 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

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

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Send to Notebook modal */
.stn-list {
    max-height: 350px;
    overflow-y: auto;
}

.stn-item {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.stn-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

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

.stn-item-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stn-loading,
.stn-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Old toast system removed - using comprehensive toast system above */

/* Responsive Design */
@media (max-width: 768px) {
    .notebook-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .notebook-title-area {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .notebook-controls {
        justify-content: space-between;
    }

    .markdown-section .section-editor {
        flex-direction: column;
    }

    .notebooks-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .notebooks-search {
        max-width: none;
    }

    .notebooks-table-container {
        overflow-x: auto;
    }

    .notebooks-table {
        min-width: 600px;
    }
}

/* ============================
   Dashboards
   ============================ */

.dashboards-view-section {
    padding: 20px;
    max-width: 100%;
    margin: 0;
}

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

.dashboards-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.dashboards-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.dashboards-search {
    flex: 1;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.dashboards-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.dashboards-table-container {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.dashboards-table {
    width: 100%;
    border-collapse: collapse;
}

.dashboards-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.dashboards-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.dashboards-table tbody tr {
    transition: var(--transition);
}

.dashboards-table tbody tr:hover {
    background: var(--bg-hover);
}

.dashboards-table tbody tr:last-child td {
    border-bottom: none;
}

.dashboards-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

.dashboards-pagination span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Dashboard Editor */
.dashboard-editor {
    padding: 0;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.dashboard-title-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dashboard-title-area h2 {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.dashboard-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Dashboard Grid */
.dashboard-grid {
    position: relative;
    min-height: 600px;
    margin: 16px;
    background:
        linear-gradient(var(--overlay-subtle) 1px, transparent 1px),
        linear-gradient(90deg, var(--overlay-subtle) 1px, transparent 1px);
    background-size: calc(100% / 12) 130px;
    border-radius: 8px;
    overflow: visible;
}

/* Dashboard Widget */
.dashboard-widget {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease;
    box-sizing: border-box;
}

.dashboard-widget:hover {
    box-shadow: var(--shadow-md);
}

.dashboard-widget.dragging {
    opacity: 0.85;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
    cursor: grabbing;
}

.dashboard-widget.resizing {
    opacity: 0.9;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
}

/* Widget Header */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.widget-header:active {
    cursor: grabbing;
}

.widget-title {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.widget-btn {
    padding: 3px 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

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

.widget-delete-btn:hover {
    color: var(--error);
}

/* Widget query preview (collapsed, readonly) */
.widget-query-preview {
    position: relative;
    height: 36px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.widget-query-highlight,
.widget-query-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: pre;
    overflow: hidden;
    box-sizing: border-box;
}

.widget-query-highlight {
    color: transparent;
    pointer-events: none;
    z-index: 1;
}

.widget-query-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    resize: none;
    z-index: 2;
}

/* Widget Content */
.widget-content {
    flex: 1;
    overflow: auto;
    padding: 8px;
    min-height: 0;
}

.widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.widget-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--error);
    font-size: 0.85rem;
    padding: 10px;
    text-align: center;
}

/* Resize Handle */
.widget-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--border-color) 50%);
    border-bottom-right-radius: 8px;
    flex-shrink: 0;
    z-index: 5;
}

.widget-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, var(--accent-tertiary) 50%);
}

/* ============================
   Context Links
   ============================ */

/* Admin management table */
.context-links-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.context-links-table th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    white-space: nowrap;
}

.context-links-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.context-links-table tr:hover td {
    background: var(--bg-hover);
}

.context-link-fields {
    max-width: 250px;
    word-break: break-word;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.context-link-regex code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-secondary);
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.context-link-actions {
    white-space: nowrap;
    display: flex;
    gap: 0.4rem;
}

.context-link-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    margin-left: 0.4rem;
    vertical-align: middle;
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Context link icons in log detail panel */
.context-links-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.35rem;
}

.context-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    padding: 0 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.65rem;
    font-family: var(--font-main);
    gap: 0.25rem;
}

.context-link-icon:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

/* Modal form helpers */
.form-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.modal-sm {
    max-width: 520px;
    width: 90%;
}

/* ================================================
   Normalizer Editor Styles
   ================================================ */

.normalizer-editor-container {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.normalizer-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.normalizer-editor-header .header-left,
.normalizer-editor-header .header-center,
.normalizer-editor-header .header-right {
    display: flex;
    align-items: center;
}

.normalizer-editor-header .header-center {
    flex: 1;
    justify-content: center;
}

.normalizer-editor-header .header-center h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.normalizer-editor-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.normalizer-editor-left,
.normalizer-editor-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.normalizer-editor-right .form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.normalizer-editor-right #normalizerMappings {
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
}

.normalizer-transforms-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 2rem;
}

.normalizer-transforms-list:empty::after {
    content: 'No transforms added.';
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.5rem 0;
}

.transform-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.transform-item-order {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.transform-item-order button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 0.7rem;
}

.transform-item-order button:hover {
    color: var(--text-primary);
}

.transform-item-order button:disabled {
    opacity: 0.2;
    cursor: default;
}

.transform-item-label {
    flex: 1;
}

.transform-item-label code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

.transform-item-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

.transform-item .btn-sm {
    flex-shrink: 0;
}

.transform-add-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;
}

.transform-add-row select {
    flex: 1;
}

.normalizer-mapping-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.normalizer-mapping-row input {
    flex: 1;
}

.normalizer-mapping-row .mapping-arrow {
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

.normalizer-mapping-row .mapping-sources {
    cursor: pointer;
}

.normalizer-mapping-row .mapping-remove {
    flex-shrink: 0;
}

.normalizer-ts-field-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.normalizer-ts-field-row input {
    flex: 1;
}

.normalizer-ts-field-row .ts-field-name {
    flex: 0.8;
}

.normalizer-ts-field-row .ts-field-format {
    flex: 1.2;
}

.mapping-sources-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mapping-sources-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.mapping-sources-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.mapping-sources-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mapping-sources-modal textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: vertical;
    margin-top: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.625rem;
    border-radius: 4px;
    box-sizing: border-box;
}

.mapping-sources-modal textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.mapping-sources-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.form-help-inline {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

/* Alert Feeds */
.alerts-sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    padding: 0 1rem;
}

.alerts-sub-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

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

.alerts-sub-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.feed-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.feed-tabs-left {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
}

.feed-sub-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

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

.feed-sub-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Feed Alerts Table */
.feed-alerts-group {
    margin-bottom: 1.25rem;
}

.feed-alerts-group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    margin-bottom: 0.25rem;
}

.feed-badge {
    background: var(--accent-bg, rgba(99,102,241,0.1));
    color: var(--accent);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.feed-alert-banner {
    background: var(--accent-bg, rgba(99,102,241,0.1));
    border: 1px solid var(--accent, #6366f1);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 4px;
}

.feed-badge-sm {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.feed-min-level-badge {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    text-transform: capitalize;
    margin-left: 0.25rem;
}

.feed-alerts-count {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.feed-alerts-table-container {
    overflow-x: auto;
}

.feed-alerts-table {
    width: 100%;
}

.feed-alert-row.disabled {
    opacity: 0.55;
}

.feed-alert-name {
    font-weight: 500;
}

.feed-alert-path {
    color: var(--text-secondary);
    font-size: 0.8rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-alert-query code {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.feed-alert-actions {
    display: flex;
    gap: 0.25rem;
}

/* Feed toggle switch */
.feed-alert-toggle {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.feed-alert-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.feed-alert-toggle .toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 9px;
    transition: background 0.2s;
}

.feed-alert-toggle .toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.feed-alert-toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.feed-alert-toggle input:checked + .toggle-slider::before {
    transform: translateX(14px);
}

/* Feeds Management */
.feeds-manage-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.feeds-table-container {
    overflow-x: auto;
}

.feeds-table {
    width: 100%;
}

.feed-row td {
    vertical-align: middle;
}

.feed-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.feed-name {
    font-weight: 500;
}

.feed-desc {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.feed-repo code {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.feed-path-badge {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.7rem;
    margin-left: 0.35rem;
}

.schedule-badge {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.sync-status {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 500;
}

.sync-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success, #22c55e);
}

.sync-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error, #ef4444);
}

.sync-pending {
    background: rgba(234, 179, 8, 0.1);
    color: var(--warning, #eab308);
}

.sync-disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.feed-actions-cell {
    display: flex;
    gap: 0.2rem;
}

.feed-last-sync {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Feed Form */
.feed-form-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

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

.feed-form-header h3 {
    margin: 0;
    font-size: 0.9rem;
}

.feed-form-body {
    padding: 1rem;
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 400;
}

.feeds-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.empty-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Spinning sync button animation */
.btn-icon.spinning svg {
    animation: spin 1s linear infinite;
}

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

/* Sortable table headers */
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
    white-space: nowrap;
}

.sortable-th:hover {
    color: var(--accent-primary);
}

/* Severity pills */
.severity-pill {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.severity-pill:hover {
    opacity: 0.85;
}

.severity-critical {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.severity-high {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.3);
}

.severity-medium {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.severity-low {
    background: rgba(96, 165, 250, 0.15);
    color: var(--info);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.severity-informational {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Label pills (clickable in table and detail panel) */
.label-pill {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.label-pill:hover {
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    background: var(--accent-glow);
}

.label-pill-more {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.label-pill-more:hover {
    border-color: var(--border-color);
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.label-pill-detail {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    max-width: none;
}

/* Feed alerts table cell adjustments */
.alert-severity-cell {
    white-space: nowrap;
}

.alert-labels-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    align-items: center;
}

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

/* Light theme severity overrides */
[data-theme="light"] .severity-critical {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error);
    border-color: rgba(220, 38, 38, 0.25);
}

[data-theme="light"] .severity-high {
    background: rgba(234, 88, 12, 0.1);
    color: #ea580c;
    border-color: rgba(234, 88, 12, 0.25);
}

[data-theme="light"] .severity-medium {
    background: rgba(180, 83, 9, 0.1);
    color: var(--warning);
    border-color: rgba(180, 83, 9, 0.25);
}

[data-theme="light"] .severity-low {
    background: rgba(37, 99, 235, 0.1);
    color: var(--info);
    border-color: rgba(37, 99, 235, 0.25);
}

[data-theme="light"] .severity-informational {
    background: rgba(100, 116, 139, 0.08);
    color: var(--text-secondary);
    border-color: rgba(100, 116, 139, 0.2);
}

[data-theme="light"] .label-pill {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

[data-theme="light"] .label-pill:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

@media (max-width: 768px) {
    .form-row-2col {
        grid-template-columns: 1fr;
    }
    .feed-alert-path {
        max-width: 120px;
    }
    .alert-labels-cell {
        max-width: 100px;
    }
}

/* ============================
   Groups & Permissions
   ============================ */

.role-viewer {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

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

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

.group-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.group-detail-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.group-detail-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.group-members-section {
    margin-top: 0.5rem;
}

.group-members-section h4 {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.group-add-member-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.fractal-permissions-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.fractal-permissions-section h3 {
    margin: 0;
}

.permissions-list {
    margin-top: 0.75rem;
}

.perm-role-select {
    width: auto;
    min-width: 100px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.perm-type-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 0.375rem;
    letter-spacing: 0.025em;
}

.perm-type-user {
    background: rgba(96, 165, 250, 0.15);
    color: var(--info);
}

.perm-type-group {
    background: rgba(156, 106, 222, 0.15);
    color: var(--accent-primary);
}

/* ============================
   Archives Section
   ============================ */

.archives-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.archives-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.25rem 0;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.archives-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.archives-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.archives-table td {
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(45, 45, 74, 0.5);
}

.archives-table tr:last-child td {
    border-bottom: none;
}

.archives-table tr:hover td {
    background: var(--bg-hover);
}

.archive-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.archive-badge-success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.archive-badge-active {
    background: rgba(156, 106, 222, 0.15);
    color: var(--accent-secondary);
}

.archive-badge-info {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.archive-badge-error {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
    cursor: help;
}

.archive-restore-dialog {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    padding: 1rem 1.25rem;
}

.archive-restore-dialog h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.archive-restore-dialog .form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.archive-restore-dialog .form-select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.8125rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.archive-restore-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 0.75rem;
}

.archive-restore-checkbox input[type="checkbox"] {
    accent-color: var(--accent);
}

.archive-restore-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.spinner-sm {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

.btn-danger-sm {
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-main);
    font-weight: 500;
}

.btn-danger-sm:hover {
    background: rgba(255, 107, 107, 0.25);
}

/* Field Statistics Bottom Drawer */
.fs-drawer {
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 6px 6px;
}

.fs-drawer-handle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.125rem 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    font-size: 0.75rem;
}

.fs-drawer-handle:hover {
    background: var(--bg-hover);
}

.fs-drawer-grip {
    width: 20px;
    height: 2px;
    background: var(--border-color);
    border-radius: 2px;
    transition: var(--transition);
}

.fs-drawer-handle:hover .fs-drawer-grip {
    background: var(--accent-primary);
}

.fs-drawer-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    flex: 1;
}

.fs-drawer-actions {
    display: flex;
    gap: 0.25rem;
}

.fs-drawer-body {
    display: none;
}

.fs-drawer.open {
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
}

.fs-drawer.open .fs-drawer-body {
    display: flex;
    flex-direction: column;
    max-height: 260px;
}

.fs-drawer.open .fs-drawer-body .fs-body {
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 0;
}

/* In drawer mode, fields display as columns */
.fs-drawer .fs-field {
    border-bottom: none;
    border-right: 1px solid var(--border-color);
    min-width: 220px;
    max-width: 300px;
    flex: 1;
}

.fs-drawer .fs-field:last-child {
    border-right: none;
}

.fs-sort-btn {
    width: 22px;
    height: 22px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: var(--font-mono);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fs-sort-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.fs-filter {
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.fs-filter-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    outline: none;
    font-family: var(--font-main);
    transition: var(--transition);
    box-sizing: border-box;
}

.fs-filter-input:focus {
    border-color: var(--accent-primary);
}

.fs-filter-input::placeholder {
    color: var(--text-muted);
}

.fs-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.fs-empty {
    padding: 1rem 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    width: 100%;
}

/* Field item */
.fs-field {
    border-bottom: 1px solid var(--border-color);
}

.fs-field:last-child {
    border-bottom: none;
}

.fs-field-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.fs-field-header:hover {
    background: var(--bg-hover);
}

.fs-field-arrow {
    font-size: 0.5rem;
    color: var(--text-muted);
    width: 10px;
    flex-shrink: 0;
}

.fs-field-name {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fs-field-badge {
    font-size: 0.625rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.0625rem 0.375rem;
    border-radius: 8px;
    flex-shrink: 0;
}

/* Expanded field detail */
.fs-field-detail {
    padding: 0.125rem 0.5rem 0.375rem 0.5rem;
}

.fs-coverage {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Value rows */
.fs-value-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.1875rem 0.375rem;
    border-radius: 3px;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.fs-value-row:hover {
    background: var(--bg-hover);
}

.fs-value-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent-primary);
    opacity: 0.08;
    border-radius: 3px;
    pointer-events: none;
}

.fs-value-text {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

.fs-value-count {
    font-size: 0.625rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 0.375rem;
    position: relative;
}

.fs-value-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 0.25rem;
    opacity: 0;
    transition: opacity 0.1s ease;
    position: relative;
}

.fs-value-row:hover .fs-value-actions {
    opacity: 1;
}

.fs-action-btn {
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

.fs-filter-in:hover {
    color: var(--success);
    border-color: var(--success);
}

.fs-filter-out:hover {
    color: var(--error);
    border-color: var(--error);
}

.fs-more {
    font-size: 0.625rem;
    color: var(--text-muted);
    padding: 0.25rem 0.375rem;
    font-style: italic;
}

/* API Key Permissions - Create Form */
.api-key-permissions-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.api-key-perm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.api-key-perm-row:last-child {
    border-bottom: none;
}

.api-key-perm-row:hover {
    background: var(--bg-hover);
}

.api-key-perm-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.api-key-perm-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.api-key-perm-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* API Key Permissions - Overview Table Badges */
.perm-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.perm-badge {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.perm-badge.perm-on {
    background: rgba(74, 222, 128, 0.12);
    color: var(--success);
    border: 1px solid rgba(74, 222, 128, 0.25);
}

.perm-badge.perm-off {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    opacity: 0.6;
}

.perm-badge.perm-all {
    background: rgba(156, 106, 222, 0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(156, 106, 222, 0.3);
}

/* "All Permissions" row separator */
.api-key-perm-all {
    border-bottom: 2px solid var(--accent-primary);
}

.api-key-perm-all .api-key-perm-name {
    color: var(--accent-primary);
}

.permissions-cell {
    min-width: 140px;
}

