:root {
    /* Matured Enterprise Palette */
    --bg-color: #fdfbf7; /* Restored Sandal Pale */
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #475569;
    --sidebar-hover: #f1f5f9;
    --main-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --primary-color: #059669; /* Emerald 600 */
    --primary-hover: #047857;
    --accent-color: #10b981;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    letter-spacing: -0.01em;
}

.app-container {
    display: flex;
    height: 100vh;
    background: var(--bg-color);
}

/* Refined Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 110;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-secondary {
    width: 0;
    background-color: #fcfdfe;
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 105;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    opacity: 0;
}

.sidebar-secondary.active {
    width: 240px;
    opacity: 1;
}

.sidebar-secondary .nav-menu {
    padding: 10px;
}

.sidebar.collapsed {
    width: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
}

/* Icon-rail mode: 56 px wide, text hidden, icons centered, tooltips on hover */
.sidebar.icon-only {
    width: 56px;
    overflow: visible;
}

/* Logo area: keep row layout, center the logo icon; collapse btn overlays on hover */
.sidebar.icon-only .logo {
    position: relative;
    justify-content: center;
    padding: 14px 4px 8px;
}

.sidebar.icon-only .logo-text {
    display: none;
}

/* Collapse btn becomes an invisible overlay over the logo icon; fades in on hover */
.sidebar.icon-only #sidebar-collapse-btn {
    position: absolute;
    inset: 0;
    opacity: 0;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 8px;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sidebar.icon-only .logo:hover #sidebar-collapse-btn {
    opacity: 1;
}

.sidebar.icon-only #sidebar-collapse-btn svg {
    transform: scaleX(-1);
}

.sidebar.icon-only .nav-menu {
    padding: 8px 4px;
    overflow: visible;
}

.sidebar.icon-only .nav-btn {
    justify-content: center;
    padding: 10px 0;
    margin: 0 4px;
    position: relative;
    overflow: visible;
}

/* Use !important to override inline display styles set by JS (admin-only, flex) */
.sidebar.icon-only .nav-label,
.sidebar.icon-only .sidebar-section-title,
.sidebar.icon-only #sidebar-recent-chats,
.sidebar.icon-only .user-info-compact,
.sidebar.icon-only .user-profile-compact > svg {
    display: none !important;
}

.sidebar.icon-only .sidebar-footer {
    padding: 8px 4px;
}

.sidebar.icon-only .user-profile-compact {
    justify-content: center;
    padding: 8px 4px;
}

.sidebar.icon-only .nav-btn[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 300;
    transition: opacity 0.15s;
}

.sidebar.icon-only .nav-btn[data-label]:hover::after {
    opacity: 1;
}

.logo {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon-wrapper {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 8px;
    flex-shrink: 0;
}

.logo-icon-wrapper img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.welcome-container .logo-icon-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    background: transparent;
    margin-bottom: 0px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-container .logo-icon-wrapper img {
    width: 110px;
    height: 110px;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.logo h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.logo-tagline {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-menu {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--sidebar-text);
    text-align: left;
    margin: 0 8px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.nav-btn i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
}

.nav-btn.active {
    background: var(--sidebar-hover);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-btn.active i {
    color: var(--primary-color);
}

.admin-only {
    display: none !important;
}

body.is-admin .admin-only {
    display: flex !important;
}

.sidebar-section-title {
    padding: 20px 20px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.recent-chats-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.time-subtitle {
    padding: 0 12px 8px;
    font-size: 0.7rem;
    color: #999;
}

.recent-chats-list {
    list-style: none;
}

.recent-chats-list li {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-chats-list li:hover {
    background: var(--sidebar-hover);
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.help-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--sidebar-text);
}

.user-profile-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
}

.user-profile-compact:hover {
    background: var(--sidebar-hover);
}

.user-avatar-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-info-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-info-compact .name {
    font-size: 0.8rem;
    font-weight: 600;
}

.user-info-compact .org {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

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

/* Primary Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 110;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 10px rgba(0,0,0,0.02);
}

/* Secondary Sidebar (Teams List) */
.sidebar-secondary {
    width: 0;
    background-color: #fdfcf9; /* Slightly lighter sandal */
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 105;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
    opacity: 0;
    box-shadow: 2px 0 8px rgba(0,0,0,0.01);
}

.sidebar-secondary.active {
    width: 240px;
    opacity: 1;
}

/* Tertiary Sidebar (Team Configuration) */
.sidebar-tertiary {
    width: 0;
    background-color: #fbf9f4; /* Even lighter sandal */
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
    opacity: 0;
    box-shadow: 1px 0 5px rgba(0,0,0,0.01);
}

.sidebar-tertiary.active {
    width: 240px;
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 0;
}

.view-section {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.view-section.active {
    display: flex;
}

.view-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--main-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 105;
    flex-shrink: 0;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #f1f5f9;
}

.header-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    margin-right: 12px;
}

.new-chat-btn-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--sidebar-border);
    background: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
}

.status-badge {
    font-size: 0.8rem;
    color: #4CAF50;
    font-weight: 600;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.chat-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-container.has-history .chat-scroll-container {
    padding-bottom: 200px;
}

.admin-scroll-container {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-color);
}

/* Order Management */
.welcome-container { order: 1; }
.chat-input-area-container { order: 2; }
.landing-extras { order: 3; }
.chat-history { order: 4; }

.chat-container.loading-layout .landing-only,
.chat-container.loading-layout .chat-history,
.chat-container.loading-layout .chat-input-area-container,
.chat-container.loading-layout .connected-integrations-bar {
    display: none !important;
}

/* Landing Flow Styling */
.landing-only {
    display: var(--landing-display, flex);
}

.chat-history {
    display: none; /* Hidden on landing */
}

/* Chat Active Mode */
.chat-container.has-history .landing-only {
    display: none !important;
}

.chat-container.has-history .chat-history {
    display: flex;
    padding: 20px 20px 40px;
}

.chat-container.has-history .chat-history::after {
    content: "";
    display: block;
    min-height: 180px; /* Spacer to ensure scroll clears the absolute input area */
    flex-shrink: 0;
}

/* Fixed search behavior during chat */
.chat-container.has-history .chat-scroll-container {
    /* padding removed; moved to .chat-history */
}

.chat-container.has-history .chat-input-area-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--main-bg);
    padding: 20px 40px 40px;
    z-index: 100;
    border-top: 1px solid var(--border-color);
}

/* Containers */
.landing-page {
    display: contents; /* Let children use order */
}

.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    padding: 30px 20px 20px; /* Reduced top gap from 60px to 30px */
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.chat-input-area-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 20px; /* Consistent padding */
}

.landing-extras {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 1100px;
    margin: 0 auto; /* Removed extreme negative margin */
    width: 100%;
    padding: 20px 20px 40px;
}

.suggestions-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 0;
}

/* Landing page history panel (Chats / Investigations tabs) */
.landing-history {
    margin-top: 20px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    overflow: hidden;
}

.landing-history-header {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--sidebar-border);
    background: var(--bg-color);
}

.landing-history-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    padding: 10px 14px 6px;
}

.landing-history-tabs {
    display: flex;
    gap: 2px;
    padding: 0 6px;
}

.landing-history-tab {
    padding: 8px 14px;
    border: none;
    border-radius: 0;
    background: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

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

.landing-history-tab.active {
    color: var(--primary-color);
    font-weight: 600;
    border-bottom-color: var(--primary-color);
}

.landing-history-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.landing-history-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.landing-history-item:hover {
    background: var(--sidebar-hover);
}

.landing-history-item i {
    color: var(--text-secondary);
    font-size: 0.72rem;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    padding-top: 2px;
}

.landing-history-item-title {
    flex: 1;
    min-width: 0;
    font-size: 0.83rem;
    color: var(--text-primary);
    white-space: normal;
    word-break: break-word;
}

.landing-history-item-date {
    font-size: 0.72rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.landing-history-empty {
    padding: 24px;
    text-align: center;
    font-size: 0.83rem;
    color: var(--text-secondary);
}

.chat-history {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Elements */
.welcome-robot-icon {
    width: 72px;
    height: 72px;
    background: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-container h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    margin: -4px 0 0 0;
}

.main-search-box {
    position: relative;
    overflow: visible;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 16px;
    padding: 24px 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.main-search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}

.main-search-box textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 1.05rem;
    min-height: 48px;
    overflow-y: hidden;
    line-height: 1.6;
    background: transparent;
    color: var(--text-primary);
    padding: 12px 0;
}

.search-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--sidebar-border);
}

.action-buttons-left {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
}

.action-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.send-btn-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sidebar-hover);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.send-btn-circle.active {
    background: var(--primary-color);
    color: white;
}
.send-btn-circle.stop-mode {
    background: #ef4444;
    color: white;
    animation: pulse-stop 1.5s ease-in-out infinite;
}
.send-btn-circle.stop-mode:hover {
    background: #dc2626;
}
@keyframes pulse-stop {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.connected-integrations-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.integration-icons {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.suggestions-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggestion-link {
    text-align: left;
    background: none;
    border: none;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 0;
}

.suggestion-link:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

/* Suggestion cards */
.suggestions-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.suggestion-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 12px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    width: 100%;
}

.suggestion-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    transform: translateY(-1px);
}

.suggestion-card:hover .suggestion-card-arrow {
    transform: translateX(3px);
}

.suggestion-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.suggestion-card-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

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

.suggestion-card-sub {
    font-size: 0.74rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.suggestion-card-arrow {
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform 0.15s;
}

/* Activity Section */
.activity-section {
    margin-top: 20px;
}

.activity-header h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.activity-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.filters {
    display: flex;
    gap: 8px;
    margin-bottom: -1px; /* Align with tab border */
}

.filter-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    background: white;
    border: 1px solid var(--sidebar-border);
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: 8px;
}

.filter-dropdown:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.view-tabs {
    border-bottom: 1px solid var(--sidebar-border);
}

.tabs, .view-tabs {
    display: flex;
    gap: 24px;
}

.tab {
    padding: 14px 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    position: relative;
    margin: 0;
    border-radius: 0;
    transition: all 0.2s;
}

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

.tab.active {
    color: var(--primary-color);
    background: none;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.activity-item {
    background: white;
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.activity-item:hover {
    transform: translateX(4px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.item-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
}

.item-time {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Investigation Cards */
.investigation-card {
    background: white;
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.investigation-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.investigation-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.investigation-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1rem;
}

.investigation-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.status-completed { background: #d1fae5; color: #065f46; }
.status-in-progress { background: #eff6ff; color: #1e40af; }
.status-failed { background: #fee2e2; color: #991b1b; }

.investigation-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.investigation-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.meta-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.investigation-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.view-session-btn {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
}
.message {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
    padding: 14px 18px;
    background: white;
    border: 1px solid var(--sidebar-border);
    border-radius: 4px 16px 16px 16px;
    max-width: 90%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.user-message {
    align-items: flex-end;
}

.user-message .message-header {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: #f8fafc;
    border-color: #e2e8f0;
    border-radius: 16px 16px 4px 16px;
}

/* Execution Phases / Steps */
.execution-phases {
    margin: 8px 0 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.phase-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 8px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #f1f5f9;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.phase-item.active {
    color: var(--primary-color);
    background: #f0f9ff;
    border-color: #e0f2fe;
    font-weight: 600;
}

.phase-item.completed {
    background: #f0fdf4;
    border-color: #dcfce7;
    color: #166534;
}

.phase-item i.status-icon {
    font-size: 0.85rem;
}

.phase-item.completed i.status-icon {
    color: #10b981;
}

.phase-item.active i.status-icon {
    animation: spin 2s linear infinite;
}

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

.confidence-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.confidence-high { background: #d1fae5; color: #065f46; }
.confidence-medium { background: #fef3c7; color: #92400e; }
.confidence-low { background: #fee2e2; color: #991b1b; }

.message-content p {
    margin-bottom: 1.25rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h1, 
.message-content h2, 
.message-content h3, 
.message-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.message-content h3 { font-size: 1.15rem; }
.message-content h4 { font-size: 1rem; }

.message-content ul, 
.message-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.5rem;
}

.message-content li > p {
    margin-bottom: 0.5rem;
}

.message-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin-bottom: 1.25rem;
    font-style: italic;
    color: var(--text-secondary);
}

.message-content code {
    background: #f1f5f9; /* Light grey background */
    color: #334155; /* Dark slate grey for code, very clean visibility */
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-weight: 600;
}

.message-content a {
    color: #1e293b; /* Dark slate grey for links */
    text-decoration: underline;
    font-weight: 600;
}

.message-content a:hover {
    color: var(--primary-color);
}

.message-content pre {
    background: #27272a; /* Darker grey for code blocks to match green accents better */
    color: #e5e7eb;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    border: 1px solid #3f3f46;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.85rem;
}

/* Markdown Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    border: 1px solid var(--sidebar-border); /* Match theme border */
}

.message-content th, .message-content td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--sidebar-border);
    border-right: 1px solid var(--sidebar-border);
}

.message-content th:last-child, .message-content td:last-child {
    border-right: none;
}

.message-content th {
    background: var(--sidebar-bg); /* Match theme sidebar background */
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 2px solid #d1d5db;
}

.message-content tr:last-child td {
    border-bottom: none;
}

.message-content tbody tr:nth-child(even) {
    background: var(--bg-color); /* Match main background */
}

.message-content tbody tr:hover {
    background: var(--sidebar-hover); /* Match theme hover */
}

.agent-message .message-content {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    padding: 16px 20px;
    border-radius: 0 16px 16px 16px;
    margin-left: 38px;
    padding-left: 20px;
}

/* Feedback bar */
.feedback-bar {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    margin-left: 38px;
    padding-top: 6px;
}
.feedback-btn {
    background: none;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}
.feedback-btn:hover:not(:disabled) {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}
.feedback-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.feedback-btn.selected {
    opacity: 1;
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}
.feedback-toast {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 8px;
    align-self: center;
    animation: fadeIn 0.2s ease;
}
.correction-form {
    margin-top: 8px;
    margin-left: 38px;
    animation: fadeIn 0.2s ease;
}
.correction-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}
.correction-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}
.correction-submit, .correction-cancel {
    padding: 4px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: none;
}
.correction-submit {
    background: var(--accent-primary);
    color: white;
}
.correction-submit:hover {
    opacity: 0.9;
}
.correction-cancel {
    background: var(--sidebar-hover);
    color: var(--text-secondary);
    border: 1px solid var(--sidebar-border);
}
.correction-cancel:hover {
    background: var(--sidebar-border);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.user-message .message-content {
    color: var(--text-primary);
    font-weight: 500;
    background: var(--sidebar-hover);
    padding: 12px 16px;
    border-radius: 16px 16px 0 16px;
    margin-left: auto;
    max-width: 80%;
    width: fit-content;
    margin-right: 38px;
}

.user-message {
    align-items: flex-end;
}

.user-message .message-header {
    flex-direction: row-reverse;
}

/* Custom Dropdown Overrides */
.custom-dropdown {
    position: relative;
}

.custom-dropdown-header {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-dropdown-header:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.custom-dropdown-list {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 8px;
    display: none;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
}

.custom-dropdown.open .custom-dropdown-list {
    display: block;
}

.custom-dropdown-option {
    padding: 8px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    color: var(--text-primary);
}

.custom-dropdown-option:hover {
    background: var(--sidebar-hover);
}

.custom-dropdown-option.selected {
    background: var(--primary-color);
}

.user-profile-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative; /* For dropdown positioning */
}

.user-profile-compact:hover {
    background: var(--sidebar-hover);
}

.profile-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 220px;
    background: white;
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    z-index: 1000;
    padding: 8px;
}

.profile-dropdown.active {
    display: flex;
}

.profile-dropdown-header {
    padding: 12px;
    text-align: left;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 4px 0;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.profile-dropdown-item:hover {
    background: var(--sidebar-hover);
}

.profile-dropdown-item i {
    width: 16px;
    color: var(--text-secondary);
}

/* Agent Loader & Thinking Steps */
.agent-dot-loader-container {
    margin-left: 38px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    padding: 12px 16px;
    border-radius: 0 12px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timer-text {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.spinner-icon {
    width: 16px;
    height: 16px;
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

.timer-badge {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.step-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.step-item {
    font-size: 0.8rem;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-style: italic;
}

.step-item.current {
    color: var(--primary-color);
    font-weight: 600;
}

.step-item.completed {
    color: #10b981;
}

.step-duration {
    font-size: 0.75rem;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Agent Feedback Styles */
.agent-feedback {
    display: flex;
    gap: 8px;
    margin-left: 58px;
    margin-top: 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.message:hover .agent-feedback {
    opacity: 1;
}

.feedback-btn {
    background: none;
    border: 1px solid var(--sidebar-border);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

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

.feedback-btn.upvote:hover {
    color: #10b981;
    background: #ecfdf5;
    border-color: #10b981;
}

.feedback-btn.downvote:hover {
    color: #ef4444;
    background: #fef2f2;
    border-color: #ef4444;
}

.feedback-integrated-msg {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #10b981;
    font-weight: 500;
    margin-left: 58px;
    margin-top: 8px;
    animation: fadeIn 0.3s ease-out;
}

/* Admin Panel Styles */
.tool-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-color);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tool-item:hover {
    border-color: var(--primary-color);
}

.tool-item.restricted {
    border-left: 4px solid #ef4444;
}

.tool-restriction-checkbox {
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
}

/* Sidebar Sub-menus */
.nav-sub-menu {
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: -2px;
    margin-bottom: 4px;
}

.nav-btn.sub-item {
    padding: 6px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    gap: 8px;
}

.nav-btn.sub-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.nav-btn.sub-item:hover {
    color: var(--text-primary);
}

.nav-btn.sub-item.active {
    background: var(--sidebar-hover);
    color: var(--primary-color);
}

/* Team Knowledge Sidebar */
.team-sidebar {
    display: none;
    flex-direction: column;
    width: 200px;
    min-width: 200px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: 16px 0;
    height: 100%;
    overflow-y: auto;
}

.team-sidebar.active {
    display: flex;
}

.main-content.has-team-sidebar {
    flex-direction: row;
}

.main-content.has-team-sidebar .view-section {
    flex: 1;
    min-width: 0;
}

.team-sidebar-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    margin: 0 8px 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.15s;
}

.team-sidebar-back:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.team-sidebar-name {
    padding: 6px 16px 10px;
    margin: 0 8px 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 8px;
}

.team-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}

.team-sidebar-item i {
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
}

.team-sidebar-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.team-sidebar-item.active {
    background: var(--sidebar-hover);
    color: var(--primary-color);
    font-weight: 600;
}

.team-sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 12px 12px 4px;
    opacity: 0.6;
}

.activity-panel {
    flex: 1;
    overflow-y: auto;
}

.activity-tab-btn:hover {
    color: var(--text-primary) !important;
    background: var(--bg-color);
}

/* @ Mention Autocomplete */
.mention-popup {
    position: fixed;
    max-height: min(360px, 50vh);
    overflow-y: auto;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 14px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.12), 0 -2px 8px rgba(0,0,0,0.06);
    z-index: 9999;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
    padding: 6px 0;
}

.mention-section-header {
    padding: 10px 16px 5px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
    position: sticky;
    top: 0;
    background: var(--sidebar-bg);
    z-index: 1;
}

.mention-section-header:first-child {
    margin-top: 0;
}

.mention-section-header i {
    font-size: 0.7rem;
    opacity: 0.5;
}

.mention-popup-hint {
    padding: 16px 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mention-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    margin: 0 6px;
    cursor: pointer;
    transition: background 0.12s ease;
    border-radius: 8px;
}

.mention-option:hover,
.mention-option.highlighted {
    background: var(--bg-color);
}

.mention-option-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #cbd5e1;
}

.mention-option-dot.firing {
    background: #ef4444;
    box-shadow: 0 0 4px rgba(239,68,68,0.4);
}

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

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

.mention-option-folder {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-option-state {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.mention-option-state.firing {
    background: #fef2f2;
    color: #ef4444;
}

.mention-option-state.inactive {
    background: var(--bg-color);
    color: var(--text-secondary);
}

.mention-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 2px;
}

.mention-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #f0fdf4;
    border: 1px solid #dcfce7;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.mention-tag.firing {
    background: #fef2f2;
    border-color: #fecaca;
    color: #ef4444;
}

.mention-tag-remove {
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

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

/* Resolve.ai List Style */
.resolve-list-container {
    background: var(--main-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.resolve-list-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resolve-tabs {
    display: flex;
    gap: 8px;
}

.resolve-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.resolve-tab.active {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.resolve-list-item {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--sidebar-border);
    transition: background 0.2s;
    cursor: pointer;
    background: var(--main-bg);
}

.resolve-list-item:hover {
    background: var(--sidebar-hover);
}

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

.resolve-list-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.resolve-list-content {
    flex: 1;
}

.resolve-list-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.resolve-list-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.resolve-list-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.sidebar-sub-header {
    padding: 12px 12px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* Integrations View (Sandal Theme) */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.integration-card {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    gap: 20px;
    transition: all 0.2s;
}

.integration-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.integration-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    flex-shrink: 0;
}

.integration-details {
    flex: 1;
}

.integration-details h4 {
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.integration-meta {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.integration-meta-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Themed Form Elements */
.themed-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

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

select.themed-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

select.themed-input option {
    background: #ffffff;
    color: #0f172a;
    padding: 8px 12px;
}

select.themed-input option:checked {
    background: #f1f5f9;
    color: #0f172a;
}

select.themed-input option:hover {
    background: #f1f5f9;
}

/* Custom Select Dropdown */
.custom-select-wrapper {
    position: relative;
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 4px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
}

.custom-select-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: background 0.15s;
}

.custom-select-option:hover {
    background: var(--sidebar-hover);
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Tertiary Sidebar (Multi-tier Navigation) */
.sidebar-tertiary {
    width: 0;
    background-color: #fbf9f4; /* Even lighter sandal */
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
    opacity: 0;
}

.sidebar-tertiary.active {
    width: 240px;
    opacity: 1;
}

.nav-menu-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
}

.sidebar-team-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--sidebar-text);
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-team-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.sidebar-team-item.active {
    background: var(--sidebar-hover);
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-team-item i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
}

.sidebar-team-item.active i {
    color: var(--primary-color);
}

/* Mermaid Diagrams */
.mermaid-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin: 16px 0;
    border: 1px solid var(--sidebar-border);
    overflow-x: auto;
    overflow-y: hidden;
    display: block;
    width: 100%;
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    text-align: center;
}

.mermaid-container::after {
    content: '\f00e'; /* fa-search-plus */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 10px;
    right: 10px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
    background: var(--sidebar-bg);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--sidebar-border);
    z-index: 10;
}

.mermaid-container:hover::after {
    opacity: 1;
}

.mermaid-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.mermaid {
    visibility: hidden; /* Prevent flash of unrendered text */
    display: inline-block;
    min-width: 800px;
}

.mermaid[data-processed="true"] {
    visibility: visible;
}

.mermaid svg {
    max-width: none !important;
    height: auto !important;
}

/* Mermaid Fullscreen Modal */
.mermaid-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.mermaid-modal.active {
    display: flex;
}

.mermaid-modal-content {
    background-color: #fff;
    margin: auto;
    padding: 30px;
    border-radius: 12px;
    width: 95vw;
    height: 95vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    cursor: default;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Zoom controls */
.mermaid-zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10001;
    border: 1px solid var(--sidebar-border);
}

.mermaid-zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--sidebar-border);
    background: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.mermaid-zoom-btn:hover {
    background: var(--sidebar-hover);
    color: var(--primary-color);
}

/* The actual scrollable area for zoomed content */
.mermaid-scroll-area {
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.mermaid-scroll-area:active {
    cursor: grabbing;
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px !important;
    height: 20px !important;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.switch input:checked + .slider {
    background-color: var(--primary-color) !important;
}

.switch input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

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

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

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

.action-btn.active#deep-investigation-btn {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#deep-mode-indicator {
    transition: opacity 0.2s;
}

#deep-mode-dismiss:hover {
    opacity: 0.6;
}

/* Service Management */
.service-card {
    transition: box-shadow 0.2s, transform 0.15s;
}

.service-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.service-type-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: capitalize;
}

.service-default-badge {
    background: #dcfce7;
    color: #16a34a;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

#admin-services-list .action-btn {
    opacity: 0.6;
    transition: opacity 0.15s;
}

#admin-services-list > div:hover .action-btn {
    opacity: 1;
}

.integration-section .action-btn {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.integration-section .service-card:hover .action-btn {
    opacity: 1;
}

/* Slide Panel (right side) */
.slide-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
    visibility: hidden;
}

.slide-panel-overlay.open {
    pointer-events: auto;
    visibility: visible;
}

.slide-panel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.slide-panel-overlay.open .slide-panel-backdrop {
    opacity: 1;
}

.slide-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 50vw;
    max-width: 90vw;
    height: 100%;
    background: var(--sidebar-bg, #fff);
    border-left: 1px solid var(--border-color, #e2e8f0);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-panel-overlay.open .slide-panel {
    transform: translateX(0);
}

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

.modal-content {
    background: var(--sidebar-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

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

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

.modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

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

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 0;
}

.modal-body .form-group label {
    font-weight: 600;
    font-size: 0.85rem;
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.modal-body .themed-input,
.modal-body select.themed-input {
    width: 100%;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
