:root {
    /* Bright, professional, corporate color palette - refined to be softer */
    --primary: #2563eb; /* Softer, modern Blue */
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --bg-main: #f8fafc; /* Very light slate for main background */
    --bg-surface: #ffffff; /* Pure white for cards/surfaces */
    
    --text-main: #1e293b; /* Softer dark for main text */
    --text-muted: #64748b; /* Slate 500 */
    
    --border-color: #e2e8f0; /* Soft border */
    
    /* Status Colors */
    --status-good: #10b981; /* Emerald */
    --status-warning: #f59e0b; /* Amber */
    --status-danger: #ef4444; /* Red */
    --status-info: #3b82f6; /* Blue */
    
    /* Shadows for depth */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
}

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

.sidebar {
    width: 340px; /* Increased width to accommodate complex menu */
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    margin-left: -340px !important; /* Slide to the left completely */
}

/* Ensure main content fills entire width when sidebar collapses */
.content, .main, .main-content {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

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

.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.sidebar-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: #ffffff;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: #f1f5f9;
    color: var(--primary, #047857);
    border-color: #cbd5e1;
    transform: translateX(-2px);
}

/* Floating Expand button when sidebar is collapsed */
.sidebar-expand-btn {
    position: fixed;
    top: 50%;
    left: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 42px;
    padding: 0;
    background: #ffffff;
    color: #047857;
    border: 1px solid #cbd5e1;
    border-left: 0;
    border-radius: 0 8px 8px 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transform: translateY(-50%);
    transition: background 0.2s ease, border-color 0.2s ease, width 0.2s ease;
    font-family: inherit;
}

.sidebar-expand-btn:hover {
    background: #f0fdf4;
    border-color: #047857;
    box-shadow: 0 6px 18px rgba(4, 120, 87, 0.2);
    width: 36px;
}

body.has-collapsed-sidebar .sidebar-expand-btn {
    display: inline-flex !important;
}

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

.logo-icon {
    font-size: 24px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

/* Tenant brand: full logo first, tenant identity directly beneath it. */
.sidebar .tenant-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.brand-mark {
    display: flex;
    align-items: center;
    min-height: 88px;
    width: 100%;
    max-width: 100%;
}

.brand-wordmark {
    color: #2563eb;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.platform-owner-brand .brand-wordmark { color: #0f3d8a; }

.personal-brand-mark { min-height: 64px; }

.workspace-owner-logo {
    display: block;
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 16px;
    background: #eff6ff;
}

.workspace-owner-fallback {
    display: grid;
    place-items: center;
    color: #fff;
    background: #2563eb;
    font-size: 18px;
    font-weight: 800;
}

.workspace-context {
    display: grid;
    gap: 3px;
    margin-top: 14px;
}

.workspace-context strong {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.workspace-context small {
    color: var(--text-muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.tenant-logo-image {
    display: block;
    width: auto;
    height: 42px;
    max-width: 220px;
    object-fit: contain;
    object-position: left center;
}

.tenant-brand-name {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.sidebar.collapsed .tenant-brand-name,
.sidebar.collapsed .brand-mark {
    opacity: 0;
    pointer-events: none;
}

/* Tenant Switcher */
.tenant-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 20px;
    padding: 10px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
}

.tenant-switcher:hover {
    border-color: #cbd5e1;
    background-color: #f1f5f9;
}

.tenant-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tenant-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

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

.tenant-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.tenant-plan {
    font-size: 11px;
    color: var(--text-muted);
}

.tenant-selector-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Sidebar Complex Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav-accordion {
    margin-bottom: 2px;
}

.nav-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background-color: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.nav-accordion-header svg {
    width: 18px;
    height: 18px;
}

.nav-accordion-content {
    padding: 12px 16px;
    display: none;
}

.nav-accordion.active .nav-accordion-content {
    display: block;
}

.nav-accordion.active .nav-accordion-header {
    background-color: transparent;
    color: var(--primary);
}

/* Focused Tenant Admin navigation: group headings act as collapsed menus. */
.role-nav-group .nav-accordion-header {
    user-select: none;
}

.role-nav-chevron {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.role-nav-group.active .role-nav-chevron {
    transform: rotate(180deg);
}

/* Ringkas untuk tautan ruang kerja di dalam accordion, termasuk ESG global. */
.nav-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.nav-subitem + .nav-subitem {
    margin-top: 3px;
}

.nav-subitem svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex: 0 0 auto;
}

.nav-subitem:hover,
.nav-subitem:focus-visible {
    background: var(--primary-light);
    color: var(--primary);
    outline: none;
}

.nav-complex-item {
    display: flex;
    gap: 12px;
    padding: 16px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    transition: background-color 0.2s;
    align-items: flex-start;
}

.nav-complex-item:hover {
    background-color: var(--primary-light);
}

.nav-complex-item .item-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

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

.item-title {
    font-weight: 600;
    font-size: 14px;
}

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

/* Sub-links grid inside complex item */
.sub-links-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-top: 12px;
    padding-left: 32px;
}

.sub-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.sub-link:hover {
    text-decoration: underline;
}

.nav-section-title {
    padding: 14px 24px 6px;
    margin: 0;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

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

.nav-item.active {
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: 21px;
}

.nav-icon {
    font-size: 18px;
}

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

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Top Header */
.top-header {
    height: 72px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border-radius: 8px;
    padding: 8px 16px;
    width: 400px;
    border: 1px solid var(--border-color);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    padding-left: 8px;
    font-family: inherit;
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
}

.action-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--status-danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
}

.badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}
.avatar.has-avatar-image { background-size: cover; background-position: center; }
.sidebar .tenant-logo-image { width: 100%; height: 88px; max-width: 100%; object-fit: contain; object-position: left center; border-radius: 0; flex: 0 0 auto; }

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

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions { position: relative; }
.account-chevron { width: 16px; height: 16px; color: var(--text-muted); margin-left: -4px; }
.account-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    z-index: 100;
    width: 260px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .16);
    overflow: hidden;
}
.account-popover[hidden] { display: none; }
.notification-popover { right: 88px; }
.account-popover-title, .account-summary { padding: 13px 14px; border-bottom: 1px solid var(--border-color); }
.account-popover-title { font-weight: 700; font-size: 14px; }
.account-summary { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.account-summary span { color: var(--text-muted); font-size: 12px; text-transform: capitalize; }
.notification-empty { color: var(--text-muted); font-size: 13px; padding: 14px; }
.popover-link, .popover-danger { display: block; box-sizing: border-box; width: 100%; padding: 11px 14px; border: 0; background: #fff; color: var(--text-main); font: inherit; font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.popover-link:hover, .popover-danger:hover { background: #f8fafc; }
.popover-danger { color: #b91c1c; border-top: 1px solid var(--border-color); }

/* Consistent, explicit navigation control; avoids thin text-arrow links. */
.back-button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; color: var(--text-main); text-decoration: none; font-size: 13px; font-weight: 600; }
.back-button:hover { background: var(--bg-main); }
.back-button::before { content: '←'; font-size: 16px; line-height: 1; }

/* Tenant onboarding uses one shared RCMS application; plan is an internal
   future billing attribute and should not be selected by administrators. */
body:has(#subdomainText) label:has(select[name="plan"]) { display: none; }
body:has(#subdomainText) .back { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; color: var(--text-main); font-size: 0; font-weight: 600; }
body:has(#subdomainText) .back::before { content: '←'; font-size: 16px; line-height: 1; }
body:has(#subdomainText) .back::after { content: 'Kembali ke Super Admin Portal'; font-size: 13px; }

/* No commercial package model is exposed until product limits are defined. */
body:has(.super-admin-label) .data-table th:nth-child(3),
body:has(.super-admin-label) .data-table td:nth-child(3) { display: none; }

/* Dashboard Content */
.dashboard-content {
    padding: 16px 32px 32px 32px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

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

.primary-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

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

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.kpi-title {
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.kpi-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* Status Utilities */
.status-good { color: var(--status-good); }
.status-warning { color: var(--status-warning); }
.status-danger { color: var(--status-danger); }
.status-info { color: var(--status-info); }

/* Widgets Grid */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.widget-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

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

.widget-title {
    font-size: 16px;
    font-weight: 600;
}

.view-all {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.widget-body {
    padding: 24px;
}

/* Update List */
.update-list, .task-list {
    list-style: none;
}

.update-item {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

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

.update-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}
.update-indicator.status-warning { background-color: var(--status-warning); }
.update-indicator.status-info { background-color: var(--status-info); }
.update-indicator.status-good { background-color: var(--status-good); }

.update-content h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.update-content p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.update-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Task List */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bg-main);
}

.task-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.task-item input[type="checkbox"] {
    margin-top: 4px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.task-item label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.task-name {
    font-size: 14px;
    font-weight: 500;
}

.badge-danger { background-color: var(--status-danger); }
.badge-warning { background-color: var(--status-warning); color: #fff; }
.badge-info { background-color: var(--status-info); }

.task-item label .badge {
    position: static;
    display: inline-block;
    width: fit-content;
}

/* Task New Layouts */
.task-header-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-assignee {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.avatar-sm {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

/* Super Admin UI Styles */
.super-admin-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 8px 12px;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.table-filters select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-main);
    background-color: var(--bg-main);
    outline: none;
}

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

.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-main);
}

.data-table tbody tr:hover {
    background-color: var(--bg-main);
}

.tenant-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.good { background-color: var(--status-good); }
.status-dot.warning { background-color: var(--status-warning); }
.status-dot.danger { background-color: var(--status-danger); }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    margin-right: 4px;
}
.icon-btn:hover {
    background-color: var(--border-color);
    color: var(--primary);
}
.icon-btn.danger:hover {
    color: var(--status-danger);
    background-color: #fee2e2;
}

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

/* Auth & Registration Forms */
.auth-body {
    background-color: #f1f5f9;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
}

.auth-container {
    background-color: var(--bg-surface);
    width: 100%;
    max-width: 680px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 40px;
    border: 1px solid var(--border-color);
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-main);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
}

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

.auth-logo .logo-text {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    line-height: 1.1;
}

.auth-form .form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background-color: white;
}

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

.form-input::placeholder {
    color: #94a3b8;
}

/* Subdomain Group */
.subdomain-group {
    display: flex;
    gap: 12px;
}

.subdomain-input {
    flex: 1;
}

.subdomain-suffix {
    flex: 1;
    background-color: var(--bg-main);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border-color);
}

/* Select Wrapper */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    cursor: pointer;
    color: #94a3b8;
}
.select-wrapper select:valid, .select-wrapper select option {
    color: var(--text-main);
}

.select-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* AI Assistant */
.ai-assistant-widget {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 999;
}

.ai-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary);
    border: none;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    color: #ffffff;
}

.ai-fab:hover {
    transform: scale(1.05);
}

.fab-icon {
    font-size: 28px;
    width: 28px;
    height: 28px;
    stroke: #ffffff;
    color: #ffffff;
}

.ai-chatbox {
    display: none;
    width: 400px;
    height: 560px;
    min-width: 320px;
    min-height: 380px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    background-color: var(--bg-surface);
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.ai-chatbox.active {
    display: flex;
}

/* Chatbox Resize Handles (Top-Left & Edges for Bottom-Right Pinned Widget) */
.ai-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    cursor: nwse-resize;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: transform 0.15s, opacity 0.15s;
    opacity: 0.85;
}
.ai-resize-handle::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border-top: 2.5px solid rgba(255, 255, 255, 0.9);
    border-left: 2.5px solid rgba(255, 255, 255, 0.9);
    border-top-left-radius: 3px;
    pointer-events: none;
}
.ai-resize-handle:hover {
    opacity: 1;
    transform: scale(1.15);
}

.ai-resize-edge-top {
    position: absolute;
    top: 0;
    left: 22px;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    z-index: 60;
}

.ai-resize-edge-left {
    position: absolute;
    top: 22px;
    left: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 60;
}

.ai-chat-header {
    padding: 16px 20px;
    background-color: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-title h4 {
    font-size: 15px;
    font-weight: 600;
}

.ai-chat-title p {
    font-size: 11px;
    opacity: 0.8;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-main);
}

.message {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    max-width: 85%;
    line-height: 1.5;
}

.ai-message {
    background-color: white;
    border: 1px solid var(--border-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user-message {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-input {
    padding: 16px;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.ai-chat-input input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 16px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
}

.ai-chat-input input:focus {
    border-color: var(--primary);
}

.send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, opacity 0.15s;
}
.send-btn:hover {
    transform: scale(1.05);
}

/* AI Floating Widget Enhancements & ESG Theme */
.ai-fab.esg-theme {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.5);
}
.ai-chatbox.esg-theme {
    border-color: #a7f3d0;
}
.ai-chatbox.esg-theme .ai-chat-header {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}
.ai-chatbox.esg-theme .send-btn {
    background-color: #059669;
}
.ai-chatbox.esg-theme .ai-chat-input input:focus {
    border-color: #059669;
}
.ai-chatbox.esg-theme .ai-quick-chip:hover {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

.ai-source-card {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 12px;
    transition: all 0.2s;
}
.esg-theme .ai-source-card {
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.ai-source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}
.ai-source-title {
    font-weight: 600;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}
.esg-theme .ai-source-title {
    color: #166534;
}
.ai-source-btn {
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 3px 8px;
    font-weight: 600;
    font-size: 11px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    transition: all 0.15s;
}
.esg-theme .ai-source-btn {
    color: #047857;
    background: #dcfce7;
    border-color: #86efac;
}
.ai-source-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.ai-source-quote {
    color: #475569;
    font-size: 11.5px;
    line-height: 1.5;
    padding: 6px 10px;
    background: rgba(255,255,255,0.85);
    border-left: 3px solid #2563eb;
    border-radius: 0 6px 6px 0;
    margin-top: 6px;
    font-style: italic;
}
.esg-theme .ai-source-quote {
    border-left-color: #10b981;
}
.ai-source-quote mark {
    background-color: #fef08a !important;
    color: #854d0e !important;
    padding: 1px 3px !important;
    border-radius: 3px !important;
    font-weight: 700 !important;
}
.ai-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 12px;
    color: #64748b;
    align-self: flex-start;
}
.ai-typing-bubble .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #94a3b8;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.ai-typing-bubble .dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-bubble .dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
.ai-quick-chip {
    white-space: nowrap;
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    font-size: 11px;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.ai-quick-chip:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.modal-content {
    background-color: var(--bg-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

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