:root {
    /* Premium Dark Mode Palette */
    --bg-base: #020205;
    --bg-surface: rgba(28, 28, 30, 0.6);
    --bg-elevated: rgba(44, 44, 46, 0.7);
    --bg-elevated-hover: rgba(58, 58, 60, 0.8);
    
    /* Text Colors */
    --text-primary: #FFFFFF;
    --text-secondary: #A1A1A6;
    --text-tertiary: #6E6E73;
    
    /* Brand & Accent Colors */
    --electric-blue: #007AFF;
    --electric-blue-glow: rgba(0, 122, 255, 0.5);
    --lime-green: #30D158;
    --lime-green-glow: rgba(48, 209, 88, 0.5);
    --system-red: #FF453A;
    --system-red-glow: rgba(255, 69, 58, 0.5);
    --system-orange: #FF9F0A;
    --system-orange-glow: rgba(255, 159, 10, 0.5);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(20px);
    
    /* Styling Variables */
    --radius-sm: 10px;
    --radius-md: 18px;
    --radius-lg: 28px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Transitions */
    --transition-fast: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: radial-gradient(circle at top right, #0a0a1a 0%, var(--bg-base) 100%);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    z-index: 1;
}

/* Premium Mesh Gradient */
.mesh-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.3) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
    filter: blur(100px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 10;
}

.logo-area {
    margin-bottom: 40px;
    padding: 0 12px;
}

.logo-placeholder {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--bg-elevated);
    color: var(--electric-blue);
}

/* --- USER MENU --- */
.sidebar-footer {
    position: relative;
    padding: 16px 8px;
    border-top: 1px solid var(--glass-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-base);
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 32px 48px 24px;
    background: transparent;
}

.greeting h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.greeting p {
    color: var(--text-secondary);
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    background: var(--bg-surface);
    border: 1px solid var(--bg-elevated);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-elevated);
}

.notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background-color: var(--system-red);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

.primary-btn {
    background: linear-gradient(135deg, var(--electric-blue), #5E5CE6);
    color: white;
    border: none;
    padding: 0 24px;
    height: 44px;
    border-radius: 22px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--electric-blue-glow);
    transition: all var(--transition-smooth);
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px var(--electric-blue-glow);
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Content Scroll Area */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 48px 48px;
}

.content-scroll::-webkit-scrollbar {
    width: 8px;
}

.content-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.content-scroll::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

/* Widgets Grid */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr) auto auto;
    gap: 20px;
    margin-bottom: 40px;
}

.widget-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    transition: all var(--transition-smooth);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.widget-card:hover {
    transform: translateY(-8px);
    border-color: var(--electric-blue);
    box-shadow: 0 12px 48px rgba(0, 122, 255, 0.15);
}

.stats-card {
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Circular Progress */
.circular-widget {
    justify-content: center;
    min-width: 160px;
}

.circular-progress {
    position: relative;
    width: 100px;
    height: 100px;
}

.circular-progress svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.circular-progress circle {
    fill: none;
    stroke-width: 7;
    stroke-linecap: round;
}

.circular-progress circle.bg {
    stroke: var(--bg-elevated);
}

.circular-progress circle.progress {
    stroke: var(--accent);
    stroke-dasharray: 282.7;
    stroke-dashoffset: 282.7;
    transition: stroke-dashoffset 1s ease-out;
}

.circular-value {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.circular-value .val {
    font-size: 18px;
    font-weight: 700;
}

.circular-value .label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Sections */
.section-container {
    background: var(--bg-surface);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 40px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.filter-group {
    display: flex;
    background: var(--bg-elevated);
    padding: 4px;
    border-radius: var(--radius-md);
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn.active {
    background: var(--bg-elevated-hover);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Table */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 20px 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.data-table tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.bot-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.bot-info {
    display: flex;
    flex-direction: column;
}

.bot-name {
    font-weight: 600;
    color: var(--text-primary);
}

.bot-id {
    font-size: 12px;
    color: var(--text-tertiary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-running {
    background: rgba(50, 215, 75, 0.1);
    color: var(--lime-green);
}

.status-running::before {
    background: var(--lime-green);
    box-shadow: 0 0 8px var(--lime-green);
}

.status-stopped {
    background: rgba(142, 142, 147, 0.1);
    color: var(--text-secondary);
}

.status-stopped::before {
    background: var(--text-secondary);
}

.status-error {
    background: rgba(255, 69, 58, 0.1);
    color: var(--system-red);
}

.status-error::before {
    background: var(--system-red);
    box-shadow: 0 0 8px var(--system-red);
}

.text-right {
    text-align: right !important;
}

/* Toggle Switch (Apple Style) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.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(--bg-elevated);
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-primary);
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background-color: var(--lime-green);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Custom Sliders */
.sliders-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.slider-card {
    background: var(--bg-base);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--bg-elevated);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.slider-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.slider-val-display {
    font-family: monospace;
    font-size: 16px;
    font-weight: 600;
}

.custom-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-elevated);
    outline: none;
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid var(--accent);
}

/* Agent Status Indicator */
.agent-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--bg-elevated);
    padding: 8px 16px;
    border-radius: 20px;
    margin-right: 16px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--lime-green);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(50, 215, 75, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(50, 215, 75, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(50, 215, 75, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(50, 215, 75, 0); }
}

.agent-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.agent-text span {
    color: var(--text-primary);
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 24px;
    height: 100%;
    overflow-x: auto;
    padding-bottom: 24px;
}

.kanban-column {
    flex: 1;
    min-width: 300px;
    background: var(--bg-surface);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
}

.kanban-header {
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--bg-elevated);
    color: var(--text-primary);
}

.kanban-cards {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    min-height: 150px;
}

.kanban-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 0;
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
}

.kanban-card-content {
    flex: 1;
    padding: 20px;
    cursor: pointer;
}

.kanban-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--electric-blue);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.kanban-card h4 {
    font-size: 14px;
    font-weight: 500;
}

.task-delete-btn {
    padding: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kanban-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.task-delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kanban-card:hover .task-delete-btn {
    color: var(--system-red);
}

.task-delete-btn:hover {
    background: rgba(255, 69, 58, 0.1);
    color: var(--system-red) !important;
}

.kanban-drag-over {
    background: var(--bg-elevated) !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Auth / Role Switch Dropdown */
.role-dropdown {
    margin-top: 8px;
    background: var(--bg-elevated);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

/* Admin Only Elements */
body[data-role="viewer"] .admin-only {
    display: none !important;
}

body[data-role="viewer"] .admin-only-input {
    pointer-events: none;
    opacity: 0.5;
}

/* --- LIGHT THEME --- */
body.light-theme {
    --bg-base: #F2F2F7;
    --bg-surface: #FFFFFF;
    --bg-elevated: #E5E5EA;
    --bg-elevated-hover: #D1D1D6;
    
    --text-primary: #000000;
    --text-secondary: #3A3A3C;
    --text-tertiary: #8E8E93;
}

body.light-theme .theme-logo {
    filter: none !important;
}

/* --- DROPDOWNS --- */
.custom-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(44, 44, 46, 0.85); /* Dark mode default */
    backdrop-filter: blur(16px);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-md);
    min-width: 160px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: 100;
}

body.light-theme .custom-dropdown {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.custom-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-elevated-hover);
}

.dropdown-item.empty {
    text-align: center;
    color: var(--text-secondary);
    cursor: default;
}
.dropdown-item.empty:hover { background: transparent; }

/* Position for role dropdown */
.user-info { position: relative; }
#role-dropdown { top: 100%; left: 0; right: auto; margin-top: 4px; }

/* Position for notification dropdown */
.notif-dropdown { right: -8px; min-width: 200px; }


/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--bg-elevated);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 24px;
    transform: scale(0.95) translateY(10px);
    transition: all var(--transition-fast);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

body.light-theme .modal-content {
    box-shadow: 0 20px 40px rgba(0,0,0,0.05);
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close-icon {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-secondary);
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.modal-close-icon:hover { background: var(--bg-elevated-hover); color: var(--text-primary); }

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.input-group label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.custom-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.custom-input:focus {
    border-color: var(--electric-blue);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px var(--electric-blue-glow), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.custom-input::placeholder {
    color: var(--text-tertiary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.secondary-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--bg-elevated);
    padding: 0 24px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.secondary-btn:hover {
    background: var(--bg-elevated);
}

/* Settings View Additions */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.profile-photo-edit {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.profile-photo-edit img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--bg-elevated);
}

/* --- TOAST NOTIFICATIONS --- */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: rgba(28, 28, 30, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success i { color: var(--lime-green); font-size: 20px; }
.toast-error i { color: var(--system-red); font-size: 20px; }

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.anim-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Glassmorphism for Modals */
.modal-content {
    background: rgba(28, 28, 30, 0.7);
    backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
}

body.light-theme .modal-content {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(30px);
}

/* --- SIDE DRAWER --- */
.side-drawer {
    position: fixed;
    top: 24px;
    right: -450px;
    width: 400px;
    height: calc(100vh - 48px);
    background: rgba(28, 28, 30, 0.7);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
    z-index: 1500;
    transition: all var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.side-drawer.show {
    right: 24px;
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-title-area h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.drawer-title-area span {
    font-family: monospace;
    color: var(--text-tertiary);
    font-size: 13px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.section-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--electric-blue);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 85%;
}

.message-item.self {
    align-self: flex-end;
}

.message-user {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.self .message-bubble {
    background: linear-gradient(135deg, var(--electric-blue), #5E5CE6);
    color: white;
    border: none;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 10px;
    color: var(--text-tertiary);
    align-self: flex-end;
}

.drawer-footer {
    padding: 24px;
    border-top: 1px solid var(--glass-border);
}

.message-input-wrapper {
    display: flex;
    gap: 12px;
}

.message-input-wrapper input {
    flex: 1;
}

.send-btn {
    background: var(--electric-blue);
    color: white;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
}

.send-btn:hover {
    background: #0062CC;
    transform: scale(1.05);
}


/* --- USER MENU DROPDOWN --- */
.user-menu {
    position: absolute;
    bottom: 85px;
    left: 8px;
    right: 8px;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    z-index: 1100;
    animation: menuSlideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

@keyframes menuSlideUp {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.user-menu.show {
    display: flex;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.menu-item i {
    font-size: 18px;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.menu-item.logout-btn {
    color: var(--system-red);
    margin-top: 4px;
    border-top: 1px solid var(--glass-border);
    border-radius: 0 0 10px 10px;
}

.menu-item.logout-btn:hover {
    background: rgba(255, 69, 58, 0.1);
    color: var(--system-red);
}

/* --- PROFILE MODAL --- */
.profile-modal-content {
    max-width: 850px;
    width: 90%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 2px;
}

.profile-layout {
    display: flex;
    gap: 48px;
    padding: 12px 0;
}

.profile-sidebar {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-right: 48px;
    border-right: 1px solid var(--glass-border);
}

.profile-photo-edit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.profile-photo-edit img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 3px solid var(--electric-blue);
    object-fit: cover;
    box-shadow: 0 0 20px var(--electric-blue-glow);
}

.profile-tabs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tab-item {
    border: none;
    background: none;
    color: var(--text-tertiary);
    padding: 12px 20px;
    text-align: left;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.tab-item.active {
    background: rgba(0, 122, 255, 0.15);
    color: var(--electric-blue);
}

.profile-main {
    flex: 1;
}

.profile-main .form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 6px;
}

.profile-main .custom-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.profile-main .custom-input:focus {
    border-color: var(--electric-blue);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px var(--electric-blue-glow);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.email-dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.email-entry {
    display: flex;
    gap: 12px;
}

.remove-email-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--system-red);
    background: rgba(255, 69, 58, 0.1);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.remove-email-btn:hover {
    background: var(--system-red);
    color: white;
}

.btn-sm {
    padding: 0 16px;
    height: 36px;
    font-size: 13px;
    border-radius: 10px;
}

/* --- NOTES & CHAT STYLES --- */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.note-card { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--glass-border); padding: 20px; border-radius: var(--radius-md); position: relative; }
.note-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 12px; color: var(--text-tertiary); }
.note-content { font-size: 14px; line-height: 1.5; color: var(--text-primary); white-space: pre-wrap; word-break: break-word; }
.note-delete-btn { background: transparent; border: none; color: var(--text-tertiary); cursor: pointer; font-size: 16px; transition: color var(--transition-fast); }
.note-delete-btn:hover { color: var(--system-red); }

.chat-container { display: flex; flex-direction: column; height: calc(100vh - 180px); background: var(--bg-surface); border: 1px solid var(--bg-elevated); border-radius: var(--radius-lg); overflow: hidden; }
.chat-messages { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.chat-input-area { display: flex; gap: 12px; padding: 16px; background: rgba(0,0,0,0.2); border-top: 1px solid var(--bg-elevated); }
.chat-input-area input { flex: 1; }

/* --- URGENCY SEGMENTED CONTROL (Kanban Card) --- */
.urgency-segment {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 3px;
}
.useg {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-family);
    padding: 4px 0;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}
.useg:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }
.useg-D.active { background: rgba(142, 142, 147, 0.25); color: #A1A1A6; }
.useg-O.active { background: rgba(0, 122, 255, 0.2); color: var(--electric-blue); box-shadow: 0 0 8px rgba(0,122,255,0.25); }
.useg-Y.active { background: rgba(255, 159, 10, 0.2); color: var(--system-orange); box-shadow: 0 0 8px rgba(255,159,10,0.25); }
.useg-A.active { background: rgba(255, 69, 58, 0.2); color: var(--system-red); box-shadow: 0 0 8px rgba(255,69,58,0.3); animation: useg-pulse 2s infinite; }

@keyframes useg-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,69,58,0.3); }
    50% { box-shadow: 0 0 14px rgba(255,69,58,0.6); }
}

.btn-sm { padding: 0 16px; height: 36px; font-size: 13px; border-radius: 10px; }

/* --- AI REPORTING VIEW STYLES --- */
.reporting-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    align-items: start;
    margin-top: 10px;
}

.reporting-left-panel {
    display: flex;
    flex-direction: column;
}

.reporting-right-panel {
    display: flex;
    flex-direction: column;
}

/* Saved Sheets List */
.saved-sheets-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

.saved-sheet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.saved-sheet-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--electric-blue);
    transform: translateX(4px);
}

.saved-sheet-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow: hidden;
}

.saved-sheet-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-sheet-date {
    font-size: 10px;
    color: var(--text-tertiary);
}

.saved-sheet-actions {
    display: flex;
    gap: 6px;
}

.saved-sheet-action-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.saved-sheet-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.saved-sheet-action-btn.delete-btn:hover {
    background: rgba(255, 69, 58, 0.15);
    color: var(--system-red);
}

/* AI Presets */
.ai-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.ai-preset-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.ai-preset-btn i {
    font-size: 20px;
}

.ai-preset-btn span {
    font-size: 11px;
    font-weight: 500;
}

.ai-preset-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--electric-blue);
}

.ai-preset-btn.active {
    background: rgba(155, 81, 224, 0.1);
    border-color: #9b51e0;
    color: #b380ff;
    box-shadow: 0 0 12px rgba(155, 81, 224, 0.2);
}

/* Disabled UI Utility */
.disabled-ui {
    position: relative;
}

.disabled-ui::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    cursor: not-allowed;
    z-index: 10;
}

.hidden-ui {
    display: none !important;
}

/* Gemini Pulsing Loader Glow */
.gemini-loader-glow {
    position: absolute;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(155, 81, 224, 0.25) 0%, transparent 70%);
    border-radius: 50%;
    animation: gemini-glow 2s infinite ease-in-out;
    pointer-events: none;
    z-index: 0;
}

@keyframes gemini-glow {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
}

.anim-pulse {
    animation: pulse 1.5s infinite;
}

/* Markdown Rendering Styles */
.markdown-body {
    word-wrap: break-word;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #FFFFFF;
}

.markdown-body h1 { font-size: 20px; border-bottom: 1px solid var(--glass-border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 14px; }

.markdown-body p {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
    padding-left: 20px;
    color: var(--text-secondary);
}

.markdown-body li {
    margin-bottom: 6px;
}

.markdown-body li strong {
    color: var(--text-primary);
}

.markdown-body code {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 13px;
    color: var(--system-orange);
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-body pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: #E5E5EA;
}

.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--glass-border);
    margin: 24px 0;
}

.markdown-body blockquote {
    border-left: 4px solid #9b51e0;
    padding-left: 16px;
    color: var(--text-secondary);
    background: rgba(155, 81, 224, 0.04);
    margin-bottom: 16px;
    padding-top: 8px;
    padding-bottom: 8px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- EXCEL AI CHAT STYLES --- */
.chat-session-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-session-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border);
}

.chat-session-item.active {
    background: rgba(0, 122, 255, 0.1);
    border-color: rgba(0, 122, 255, 0.3);
}

.chat-session-item .chat-icon {
    font-size: 20px;
    color: var(--electric-blue);
    background: rgba(0, 122, 255, 0.1);
    padding: 8px;
    border-radius: 50%;
    display: flex;
}

.chat-session-info {
    flex: 1;
    overflow: hidden;
}

.chat-session-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.chat-session-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

.chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.model {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .chat-bubble {
    background: var(--electric-blue);
    color: #FFF;
    border-bottom-right-radius: 4px;
}

.chat-message.model .chat-bubble {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-timestamp {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    margin-bottom: 8px;
}

/* Loading Dots Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Responsive Adjustments */

/* Tablets & iPads (max-width: 1024px) */
@media (max-width: 1024px) {
    .reporting-grid {
        grid-template-columns: 1fr;
    }
    .widgets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .profile-layout {
        flex-direction: column;
    }
    .profile-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }
    .sidebar {
        width: 220px;
    }
}

/* Mobile & Smaller Tablets (max-width: 768px) */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        transition: left 0.3s ease;
        z-index: 1000;
        width: 260px;
    }
    
    .sidebar.open {
        left: 0;
    }

    .mobile-menu-toggle {
        display: inline-flex !important;
        margin-right: 12px;
    }

    .widgets-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .greeting {
        order: 2;
        width: 100%;
    }

    .topbar-actions {
        order: 1;
        margin-left: auto;
    }

    .kanban-board {
        flex-direction: column;
        height: auto;
    }

    .kanban-column {
        min-height: 300px;
        margin-bottom: 16px;
    }
    
    .reporting-left-panel, .reporting-right-panel {
        width: 100%;
    }
    
    .sliders-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
    }
}

/* Specific tweaks for iPhones (max-width: 480px) */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }
    
    .login-card {
        padding: 24px;
    }

    .agent-status {
        display: none !important; /* Hide agent status on very small screens */
    }
    
    .topbar h1 {
        font-size: 18px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .stat-value {
        font-size: 20px;
    }
}

/* Autofill styling to match dark mode */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #1e1e22 inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* OpenAI SVG Logo theme colors */
.openai-svg-logo {
    color: #FFFFFF; /* White by default in dark mode */
    transition: color var(--transition-fast);
}

body.light-theme .openai-svg-logo {
    color: #000000; /* Black in light mode */
}
