/* FluxAgent Analytics - Enterprise Theme */
/* Modern Dark Mode Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* --- Palette: Deep Enterprise Dark --- */
    --bg-app: #0f1115;
    /* Deepest background */
    --bg-panel: #161b22;
    /* Sidebar/Panels */
    --bg-card: #1c2128;
    /* Cards */
    --bg-hover: #2d333b;
    /* Hover states */
    --bg-input: #0d1117;
    /* Input fields */

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-accent: #58a6ff;

    /* Borders */
    --border-subtle: rgba(240, 246, 252, 0.1);
    --border-muted: #30363d;
    --border-active: #58a6ff;

    /* Brand Accents */
    --accent-primary: #4f46e5;
    /* Indigo for Professional Primary Actions */
    --accent-blue: #2f81f7;
    /* Links / Info */
    --accent-purple: #a371f7;
    /* AI / Analytics */
    --accent-red: #da3633;
    /* Danger / Error */
    --accent-orange: #d29922;
    /* Warning */

    /* Gradients */
    --grad-primary: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%);
    --grad-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);

    /* Dimensions */
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 64px;
    --header-height: 70px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 12px;

    /* Effects */
    --shadow-sm: 0 1px 0 rgba(27, 31, 36, 0.04);
    --shadow-md: 0 3px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --transition-speed: 0.2s;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Light Mode Overrides (if toggled) */
html.light {
    --bg-app: #f6f8fa;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f3f4f6;
    --bg-input: #ffffff;

    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;

    --border-subtle: #d0d7de;
    --border-muted: #d0d7de;

    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    /* App container handles scroll */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.spa-view {
    height: 100%;
    width: 100%;
    display: none;
    /* Hidden by default */
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-muted);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.2, 0, 0, 1);
    z-index: 50;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    overflow: hidden;
}

.logo {
    min-width: 32px;
    height: 32px;
    background: var(--accent-blue);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-right: 12px;
    cursor: pointer;
}

.sidebar-brand-text {
    flex: 1;
    opacity: 1;
    transition: opacity var(--transition-speed);
}

.sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    pointer-events: none;
    width: 0;
    margin: 0;
    overflow: hidden;
}

.sidebar-title {
    font-weight: 700;
    font-size: 15px;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
    padding: 5px;
    border-radius: var(--radius-sm);
}

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

.sidebar.collapsed .sidebar-toggle {
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Hide scrollbar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-muted);
    border-radius: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    height: 40px;
    margin-top: 4px;
}

.bottom-meta {
    border-top: 1px solid var(--glass-border);
    margin-top: 0;
    padding-top: 5px;
}

/* User Profile Section */
.user-profile-section {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    margin: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    gap: 12px;
    transition: all 0.2s ease;
}

.user-profile-section:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B, #556270);
    color: white;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

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

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    /* Ensure it sticks to bottom if parent is flex col */
    background: var(--bg-panel);
}

.version-info {
    line-height: 1.4;
}

.sidebar.collapsed .sidebar-footer {
    flex-direction: column;
    padding: 12px 0;
    text-align: center;
    gap: 8px;
}

.sidebar.collapsed .version-info {
    display: none;
}

.sidebar.collapsed .info-icon {
    display: block;
    font-size: 14px;
}

/* Sidebar collapsed state for profile */
.sidebar.collapsed .user-profile-section {
    padding: 8px;
    margin: 10px 8px;
    justify-content: center;
    background: transparent;
    border: none;
}

.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn {
    display: none;
}

.sidebar.collapsed .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

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

.nav-item.active {
    background-color: rgba(47, 129, 247, 0.1);
    color: var(--accent-blue);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    width: 3px;
    background-color: var(--accent-blue);
    border-radius: 0 4px 4px 0;
}

.nav-item i {
    min-width: 24px;
    text-align: center;
    font-size: 16px;
    margin-right: 12px;
}

.nav-item span {
    transition: opacity var(--transition-speed);
}

.sidebar.collapsed .nav-item span {
    opacity: 0;
    display: none;
}

/* In collapsed mode, rely on tooltip (title attribute) */

.nav-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: 8px 12px;
}

.nav-spacer {
    flex: 1;
}

.text-accent {
    color: var(--accent-blue);
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-app);
    overflow: hidden;
}

/* Header */
.header {
    height: var(--header-height);
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-muted);
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
}

.header-context {
    display: flex;
    align-items: center;
    gap: 12px;
}

.context-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background-color: var(--bg-hover);
    /* input bg for contrast */
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
}

.context-details {
    display: flex;
    flex-direction: column;
}

.context-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.context-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-toolbar {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin: 0 24px;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-left: 24px;
    border-left: 1px solid var(--border-subtle);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    border: 2px solid var(--bg-panel);
    box-shadow: 0 0 0 1px var(--border-muted);
    transition: transform 0.2s ease;
}

.user-avatar-container:hover .user-avatar {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px var(--accent-blue);
}

/* Header Dropdown */
.user-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    width: 220px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.user-dropdown.show {
    display: flex;
}

.dropdown-header-info {
    padding: 16px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
}

.dropdown-user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 2px;
}

.dropdown-user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.dropdown-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}

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

.dropdown-item i {
    width: 16px;
    text-align: center;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

.notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background-color: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg-panel);
}

/* Page Content */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    position: fixed;
    top: 80px;
    left: 260px;
    right: 0;
    bottom: 0;
}

/* --- COMPONENTS --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    /* Subtly rounded */
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    gap: 8px;
    line-height: 20px;
    white-space: nowrap;
    user-select: none;
    height: 32px;
    cursor: pointer;
    /* Fixed height for consistency */
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
    background: #4338ca;
    /* Darker Indigo */
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
}

.btn-secondary {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-muted);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background-color: #373e47;
    /* Slightly lighter than bg-hover */
    border-color: var(--text-secondary);
}

html.light .btn-secondary:hover {
    background-color: #e5e7eb;
    color: #111827;
}

.btn-danger {
    background-color: rgba(220, 38, 38, 0.1);
    color: #ef4444;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background-color: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.3);
}

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

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

/* Icon Button - Enterprise Style */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
}

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

.btn-icon.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-primary);
    border-color: rgba(79, 70, 229, 0.2);
}

/* Graph Card Titles */
.graph-card-title {
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 14px !important;
}

/* Ensure visibility in light mode */
html.light .graph-card-title {
    background: var(--accent-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Cards */
.card,
.glass-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    overflow: hidden;
}

/* Enhanced Glass/Rich Card */
.glass-card {
    background-color: var(--bg-card);
    /* Adaptive background */
    border: 1px solid var(--border-muted);
    /* box-shadow: var(--shadow-sm); removed to avoid conflict if needed, or keep */
    position: relative;
    /* For the gradient overlay */
}

/* Add a subtle gradient ONLY in dark mode if desired, or just use bg-card */
html:not(.light) .glass-card {
    background: linear-gradient(145deg, rgba(28, 33, 40, 0.9), rgba(28, 33, 40, 0.6));
    border: 1px solid rgba(240, 246, 252, 0.1);
    backdrop-filter: blur(10px);
}

html.light .glass-card {
    background: #ffffff;
    border: 1px solid #d0d7de;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Light Mode for KPI Cards */
html.light .kpi-card {
    background: #ffffff;
    border: 1px solid #d0d7de;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10000;
    pointer-events: none;
    /* allow click through */
}

.toast {
    pointer-events: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-left: 4px solid var(--accent-blue);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--text-primary);
    animation: slideIn 0.3s ease-out forwards;
}

.toast-success {
    border-left-color: var(--accent-primary);
}

.toast-error {
    border-left-color: var(--accent-red);
}

.toast-warning {
    border-left-color: var(--accent-orange);
}

.toast-icon {
    font-size: 18px;
    margin-top: 2px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    /* Toggled by JS */
    align-items: center;
    justify-content: center;
}

.modal {
    background-color: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background-color: var(--bg-panel);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* Utility Defaults for JS-generated content */
.text-theme-heading {
    color: var(--text-primary);
}

.text-theme-secondary {
    color: var(--text-secondary);
}

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

.bg-theme-bg {
    background-color: var(--bg-app);
}

.bg-theme-elevated {
    background-color: var(--bg-hover);
}

.border-theme-border {
    border-color: var(--border-subtle);
}

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

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

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

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

/* Sidebar Toggle */
.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: auto;
}

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

.sidebar.collapsed .sidebar-toggle {
    margin: 0 auto;
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(0deg);
}

/* --- FORM CONTROLS --- */
.form-control {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.2);
}

/* --- GRAPH BUILDER LAYOUT --- */
.graph-builder {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    height: calc(100vh - 140px);
    /* Fill remaining height */
}

.builder-options {
    overflow-y: auto;
    padding-right: 4px;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* --- Anomalies Redesign --- */
.anomalies-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.kpi-card .label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}

.kpi-card .subtext {
    font-size: 13px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.priority-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.priority-card {
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    border-left-width: 4px;
    /* Color set inline via JS based on severity */
    padding: 20px;
    transition: transform 0.2s;
}

.priority-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.priority-card h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
}

.priority-card p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Strip Plot Visualization */
.strip-plot-container {
    position: relative;
    height: 60px;
    background: var(--bg-color);
    /* Slightly darker than card */
    border-radius: 6px;
    margin-top: 15px;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.strip-plot-track {
    position: relative;
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
}

.strip-plot-zone {
    position: absolute;
    height: 20px;
    /* Thicker than track */
    top: 50%;
    transform: translateY(-50%);
    background: rgba(46, 204, 113, 0.2);
    /* Green tint */
    border: 1px solid rgba(46, 204, 113, 0.5);
    border-radius: 4px;
    /* width/left set via JS */
}

.strip-plot-point {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-red);
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.7;
    transition: opacity 0.2s;
    cursor: pointer;
    z-index: 2;
}

.strip-plot-point:hover {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5);
    z-index: 3;
}

/* --- Enterprise Anomaly Grid --- */
.anomaly-grid-container {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-top: 30px;
    border: 1px solid var(--border-color);
}

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

.anomaly-table th {
    text-align: left;
    padding: 16px 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-color);
    border-bottom: 2px solid var(--border-color);
}

.anomaly-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.anomaly-table tr:hover {
    background-color: var(--bg-hover);
}

.metric-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 15px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.stat-pill.skewed {
    background: rgba(241, 196, 15, 0.1);
    color: #f39c12;
    border-color: rgba(241, 196, 15, 0.3);
}

.stat-pill.normal {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
    border-color: rgba(46, 204, 113, 0.3);
}

.sparkline-cell {
    width: 150px;
    height: 40px;
    position: relative;
    padding: 0;
}

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.expand-btn.expanded {
    transform: rotate(180deg);
    color: var(--text-primary);
}

.detail-row {
    background: var(--bg-color);
    display: none;
}

.detail-row.visible {
    display: table-row;
}

.detail-container {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-box {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-box label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.stat-box .val {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

/* --- Anomaly Inspector Playground --- */
.inspector-sidebar {
    width: 350px;
    flex: 0 0 350px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    transition: width 0.2s;
}

.inspector-main {
    position: relative;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border-muted);
    border-radius: 3px;
}

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

/* Range Slider */
.form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-muted);
    border-radius: 2px;
    outline: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-panel);
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* --- INSPECTOR SPECIFIC STYLES --- */
.inspector-sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-muted);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 24px;
    height: 100%;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    /* Subtle depth */
    z-index: 10;
}

.inspector-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inspector-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.feature-list-container {
    background: var(--bg-input);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    max-height: 380px;
    min-height: 380px;
    overflow-y: auto;
    padding: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

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

/* Custom Checkbox */
.custom-checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    background-color: var(--bg-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.custom-checkbox:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.custom-checkbox:checked::after {
    content: '✓';
    font-size: 10px;
    color: white;
    font-weight: bold;
}

/* Range Slider Refinement */
input[type=range] {
    width: 100%;
    height: 4px;
    background: var(--border-muted);
    border-radius: 2px;
    outline: none;
    opacity: 0.8;
    transition: opacity .2s;
    -webkit-appearance: none;
}

input[type=range]:hover {
    opacity: 1;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 0 2px var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Light Mode specific fixes for Inspector */
body.light .inspector-sidebar {
    background: #fcfcfc;
    border-right: 1px solid #e1e4e8;
}

body.light .feature-list-container {
    background: #ffffff;
    border-color: #d0d7de;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

body.light .form-control {
    background: #ffffff;
    border-color: #d0d7de;
    color: #24292f;
}

body.light .form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.2);
}

.btn-group {
    display: inline-flex;
    border-radius: 6px;
    background: var(--bg-hover);
    padding: 2px;
    border: 1px solid var(--border-muted);
}

.btn-group .btn {
    border: none;
    background: transparent;
    height: 24px;
    width: 24px;
    padding: 0;
    border-radius: 4px;
    color: var(--text-secondary);
}

.btn-group .btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Utility Animations & Helpers */
.zoom-hover {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
}

.zoom-hover:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.cursor-pointer {
    cursor: pointer;
}

.ml-auto {
    margin-left: auto;
}

.mr-2 {
    margin-right: 8px;
}

/* Data Viewer Filtering UI */
.dv-filter-bar {
    padding: 10px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-height: 50px;
}

.dv-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(47, 129, 247, 0.1);
    border: 1px solid rgba(47, 129, 247, 0.2);
    border-radius: 16px;
    font-size: 13px;
    color: var(--accent-blue);
    font-weight: 500;
}

.dv-filter-chip .close-btn {
    cursor: pointer;
    opacity: 0.6;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    transition: all 0.2s;
}

.dv-filter-chip .close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    opacity: 1;
}

.dv-add-filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 10px;
    background: var(--bg-hover);
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    animation: fadeIn 0.2s ease-out;
}

.dv-add-filter-btn {
    background: transparent;
    border: 1px dashed var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.dv-add-filter-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(47, 129, 247, 0.05);
}

/* ================= PRO LOADING & EMPTY STATES ================= */

.pro-loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    background: var(--bg-app);
    /* Context aware */
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.pro-loader-content {
    text-align: center;
    max-width: 400px;
}

/* Spinner Animation */
.pro-spinner-ring {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 64px;
    margin-bottom: 24px;
}

.pro-spinner-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 50px;
    height: 50px;
    margin: 8px;
    border: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: pro-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: var(--accent-primary) transparent transparent transparent;
}

.pro-spinner-ring div:nth-child(1) {
    animation-delay: -0.45s;
}

.pro-spinner-ring div:nth-child(2) {
    animation-delay: -0.3s;
}

.pro-spinner-ring div:nth-child(3) {
    animation-delay: -0.15s;
}

@keyframes pro-ring {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Progress Bar */
.pro-progress-wrapper {
    width: 240px;
    height: 4px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 16px;
    position: relative;
}

.pro-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-purple));
    width: 30%;
    border-radius: 4px;
    animation: pro-progress-indeterminate 1.5s infinite ease-in-out;
    position: relative;
}

/* Shine effect on progress bar */
.pro-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.4) 50%,
            rgba(255, 255, 255, 0) 100%);
    transform: translateX(-100%);
    animation: form-shimmer 2s infinite;
}

@keyframes pro-progress-indeterminate {
    0% {
        transform: translateX(-100%);
        width: 20%;
    }

    50% {
        transform: translateX(0%);
        width: 80%;
    }

    100% {
        transform: translateX(100%);
        width: 20%;
    }
}

.pro-loader-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.pro-loader-sub {
    font-size: 13px;
    color: var(--text-secondary);
}

/* EMPTY STATE */
.pro-empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    background: var(--bg-app);
}

.pro-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(168, 85, 247, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.pro-empty-icon i {
    font-size: 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pro-empty-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.pro-empty-desc {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 480px;
    margin-bottom: 32px;
    line-height: 1.5;
}

.pro-btn-glow {
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.pro-btn-glow:hover {
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

/* ========================================= */
/* FLEET DEFECTS / ANOMALIES MODULE STYLES */
/* ========================================= */

.anom-container {
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

/* Cards */
.anom-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-bottom: 24px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
}

.anom-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.15);
}

.anom-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.03), transparent);
}

.anom-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.anom-card-body {
    padding: 20px;
    min-height: 300px;
    position: relative;
    color: var(--text-secondary);
}

/* KPIs */
.anom-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

.kpi-stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.kpi-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
    opacity: 0.8;
}

.kpi-stat-value {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0;
    background: linear-gradient(to bottom, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--text-primary);
    /* Fallback */
}

.kpi-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ADVANCED AI INSIGHT BOX */
.ai-insight-box {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0.02) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}

.ai-insight-box::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 70%);
    pointer-events: none;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-icon-pulse {
    width: 32px;
    height: 32px;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
    animation: pulse 2s infinite;
}

.ai-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.ai-badge {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: inline-block;
}

/* Graph Footer AI - Enhanced */
.graph-ai-footer {
    margin-top: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0 0 12px 12px;
    margin: 20px -20px -20px -20px;
    /* Bleed to edges */
    padding: 20px;
}

.ai-item {
    position: relative;
    padding-left: 12px;
}

.ai-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border-subtle);
    border-radius: 2px;
}

.ai-item:nth-child(1)::before {
    background: var(--accent-blue);
}

.ai-item:nth-child(2)::before {
    background: var(--accent-orange);
}

.ai-item:nth-child(3)::before {
    background: var(--accent-primary);
}

.ai-item h5 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-item p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Toolbar */
.anom-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-dashboard-add {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-muted);
    color: var(--text-secondary);
    background: transparent;
    transition: all 0.2s;
    cursor: pointer;
}

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

/* Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* --- DATA VIEWER CONTEXT MENU --- */
.dv-context-menu {
    position: fixed;
    z-index: 10000;
    width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    display: none;
    flex-direction: column;
    animation: fadeIn 0.1s ease-out;
}

.dv-menu-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
}

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

.dv-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
}

.dv-menu-item:hover i {
    color: var(--accent-blue);
}

.dv-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* Report Library Styles */
.lib-tab {
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

.lib-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue) !important;
}

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

.dv-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

.dv-menu-item.danger:hover i {
    color: var(--accent-red);
}

/* --- ANOMALY INSPECTOR & TEMPLATES --- */

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 16px;
    gap: 2px;
}

.tab {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    text-align: center;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-radius: 4px 4px 0 0;
}

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

.tab-full-width .tab {
    flex: 1;
}

/* Uniform Buttons */
.btn-uniform {
    height: 36px;
    width: 100%;
    margin-bottom: 8px;
    justify-content: center;
    font-weight: 600;
}

/* Template Items */
.template-item {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-item:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.template-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.template-item-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.template-item-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.template-item-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: 12px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 16px 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}


@keyframes fadeScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Graph Builder Template Cards --- */
.template-card {
    background: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.template-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(47, 129, 247, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(47, 129, 247, 0.2);
}

.template-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    flex: 1;
}

.template-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
    opacity: 0;
    transition: opacity 0.2s;
}

.template-card:hover .template-card-footer {
    opacity: 1;
}

.t-btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid var(--border-muted);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

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

.t-btn-delete:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: rgba(218, 54, 51, 0.1);
}