/* ===== CSS VARIABLES ===== */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    
    --sidebar-width: 260px;
    --header-height: 70px;
    
    --transition: all 0.3s ease;
}

/* Override sidebar width to 0 on mobile so margin-left: var(--sidebar-width) = 0 */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

input, select {
    font-family: inherit;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo i {
    font-size: 28px;
    color: var(--primary-color);
}

.logo h2 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
}

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

.nav-item:hover,
.nav-item.active {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.nav-item.active::before {
    height: 24px;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
}

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

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    flex: 1;
}

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

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

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    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: 999;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    display: none;
    color: var(--text-primary);
    font-size: 20px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-primary);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-width: 300px;
}

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

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
}

.notification-btn {
    position: relative;
    color: var(--text-primary);
    font-size: 20px;
    padding: 8px;
    transition: var(--transition);
}

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

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

/* Remark badge sits below the threat badge */
.badge-remark {
    position: absolute;
    top: 16px;
    right: 0;
    background: #818cf8;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    display: none;
    padding: 32px;
    animation: fadeIn 0.3s ease;
}

.page-content.active {
    display: block;
}

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

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info-color);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-change {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-change.positive {
    color: var(--success-color);
}

/* ===== CHARTS ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

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

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.time-filter {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.chart-container {
    height: 300px;
}

/* ===== RECENT THREATS ===== */
.recent-threats {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.view-all {
    color: var(--primary-color);
    font-size: 14px;
    transition: var(--transition);
}

.view-all:hover {
    color: var(--secondary-color);
}

.threats-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.threat-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    border-left: 4px solid;
    transition: var(--transition);
}

.threat-item:hover {
    transform: translateX(4px);
}

.threat-item.high {
    border-left-color: var(--danger-color);
}

.threat-item.medium {
    border-left-color: var(--warning-color);
}

.threat-item.low {
    border-left-color: var(--info-color);
}

.threat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.threat-item.high .threat-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.threat-item.medium .threat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

.threat-item.low .threat-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info-color);
}

.threat-details {
    flex: 1;
}

.threat-details h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

.threat-details p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

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

.threat-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    align-self: center;
}

.threat-badge.high {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.threat-badge.medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

.threat-badge.low {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info-color);
}

/* ===== EMAIL MONITORING ===== */
.email-monitoring {
    max-width: 100%;
}

.monitoring-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.filter-group {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 10px 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.email-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.email-item {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    align-items: start;
    transition: var(--transition);
}

.email-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.email-checkbox {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.email-status {
    font-size: 24px;
}

.email-item.safe .email-status {
    color: var(--success-color);
}

.email-item.dangerous .email-status {
    color: var(--danger-color);
}

.email-item.suspicious .email-status {
    color: var(--warning-color);
}

.email-content {
    flex: 1;
}

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

.email-header h4 {
    font-size: 16px;
    font-weight: 600;
}

.email-time {
    font-size: 13px;
    color: var(--text-muted);
}

.email-sender {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.email-preview {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.threat-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.btn-icon {
    padding: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 16px;
    transition: var(--transition);
}

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

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

/* ===== THREATS PAGE ===== */
.threats-container {
    max-width: 100%;
}

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

.threats-summary h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

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

.threat-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: var(--transition);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.category-card i {
    font-size: 36px;
    margin-bottom: 16px;
}

.category-card.phishing i {
    color: var(--danger-color);
}

.category-card.malware i {
    color: var(--warning-color);
}

.category-card.spoofing i {
    color: var(--info-color);
}

.category-card.other i {
    color: var(--text-muted);
}

.category-card h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.category-count {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.category-percentage {
    font-size: 14px;
    color: var(--text-muted);
}

.detailed-threats {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.threat-detail-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

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

.threat-severity {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.threat-severity.high {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.threat-date {
    font-size: 13px;
    color: var(--text-muted);
}

.threat-detail-card h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.threat-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

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

.info-item label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.info-item span {
    font-size: 14px;
    color: var(--text-primary);
}

.threat-actions {
    display: flex;
    gap: 12px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    cursor: pointer;
}

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

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* ===== HONEYPOT PAGE ===== */
.honeypot-container {
    max-width: 100%;
}

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

.honeypot-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

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

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

.toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--success-color);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: var(--transition);
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success-color);
}

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

.honeypot-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.honeypot-stat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.honeypot-stat i {
    font-size: 32px;
    color: var(--primary-color);
}

.honeypot-stat h4 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.active-honeypots {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.active-honeypots h3 {
    font-size: 20px;
    margin-bottom: 24px;
}

.honeypot-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.honeypot-session {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

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

.session-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.session-status.active {
    background: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
}

.session-header h4 {
    flex: 1;
    font-size: 16px;
}

.session-duration {
    font-size: 13px;
    color: var(--text-muted);
}

.session-details {
    margin-bottom: 16px;
}

.session-details p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.session-details strong {
    color: var(--text-primary);
}

.session-actions {
    display: flex;
    gap: 12px;
}

/* ===== SETTINGS PAGE ===== */
.settings-container {
    max-width: 900px;
}

.settings-container h2 {
    font-size: 28px;
    margin-bottom: 32px;
}

.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.setting-info h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

.setting-info p {
    font-size: 13px;
    color: var(--text-muted);
}

.gmail-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    margin-bottom: 16px;
}

.gmail-status i {
    color: var(--success-color);
    font-size: 20px;
}

.gmail-status span {
    color: var(--success-color);
    font-weight: 500;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    position: fixed;
    top: 100px;
    right: -400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--danger-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: start;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    transition: right 0.4s ease;
}

.toast.show {
    right: 24px;
}

.toast i {
    font-size: 24px;
    color: var(--danger-color);
}

.toast-content h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

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

.toast-close {
    color: var(--text-muted);
    font-size: 20px;
    transition: var(--transition);
}

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

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* ── Prevent horizontal overflow globally ── */
    html, body { overflow-x: hidden !important; max-width: 100vw !important; }
    * { max-width: 100vw; }

    .sidebar {
        transform: translateX(-100%);
        transition: var(--transition);
        z-index: 999;
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 260px;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* ── Critical: override the sidebar margin ── */
    .main-content,
    div.main-content {
        margin-left: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        position: relative;
    }

    /* ── Sidebar overlay backdrop ── */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 998;
    }
    .sidebar-overlay.active { display: block; }
    
    .menu-toggle { display: block; }
    
    .page-content {
        padding: 16px;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .header {
        padding: 0 16px;
        width: 100%;
        box-sizing: border-box;
        margin-left: 0 !important;
    }
    
    .search-box { display: none; }
    
    /* ── Stats cards — 2 per row on mobile ── */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

    /* ── Charts stack ── */
    .charts-grid { grid-template-columns: 1fr; }

    .monitoring-controls { flex-direction: column; align-items: stretch; }
    .filter-group { flex-wrap: wrap; }
    .threat-categories { grid-template-columns: 1fr; }
    .threat-info-grid { grid-template-columns: 1fr; }

    .stat-card, .email-item, .threat-item,
    .chart-card, .honeypot-card, .session-card {
        max-width: 100%;
        box-sizing: border-box;
    }

    table { display: block; overflow-x: auto; }

    /* ── Login: hide left panel, show only card ── */
    #loginScreen {
        flex-direction: column;
        overflow-x: hidden;
    }
    .login-left { display: none !important; }
    .login-right {
        width: 100% !important;
        padding: 2rem 1.25rem !important;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
    }
    .login-card {
        width: 100% !important;
        max-width: 420px !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 20px;
    }
    
    .stat-number {
        font-size: 24px;
    }

    /* ── Single column stats on very small screens ── */
    .stats-grid { grid-template-columns: 1fr; }
    
    .email-item {
        flex-direction: column;
    }
    
    .threat-actions,
    .session-actions {
        flex-direction: column;
    }
    
    .toast {
        max-width: calc(100vw - 48px);
    }

    /* ── Header shrink ── */
    .header { height: auto; min-height: 60px; padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
    .page-title { font-size: 17px; }
}

/* ============================================================
   NEW STYLES — Login, Modal, Empty/Loading States, Logout
   ============================================================ */

/* ── LOGIN SCREEN ─────────────────────────────────────────── */
#loginScreen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.08) 0%, transparent 60%);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 3rem 2.5rem;
    width: 420px;
    max-width: calc(100vw - 40px);
    text-align: center;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.login-logo i {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    display: block;
}

.login-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: left;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-feature i {
    color: var(--primary-color);
    width: 20px;
    text-align: center;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    color: #333;
    padding: 0.9rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
    transition: box-shadow 0.2s, transform 0.2s;
    margin-bottom: 1.25rem;
}

.btn-google:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transform: translateY(-2px);
}

.login-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ── LOGOUT BUTTON in sidebar ─────────────────────────────── */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.logout-btn {
    color: var(--text-muted);
    font-size: 16px;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
    flex-shrink: 0;
}

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

/* ── SCAN STATUS DOT ──────────────────────────────────────── */
.scan-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--success-color);
}

.scan-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(1.3); }
}

/* ── LOADING & EMPTY STATES ───────────────────────────────── */
.loading-state, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    color: var(--text-muted);
    text-align: center;
}

.loading-state i, .empty-state i {
    font-size: 2.5rem;
    opacity: 0.5;
}

.empty-state.error i { color: var(--danger-color); opacity: 0.8; }
.empty-state a { color: var(--primary-color); cursor: pointer; }

/* ── EMAIL COUNT INFO ─────────────────────────────────────── */
.email-count-info {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0;
}

/* ── EMAIL DETAIL MODAL ───────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    padding: 20px;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 600px;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    flex: 1;
    margin-right: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close {
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.modal-email-meta {
    background: var(--bg-primary);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-meta-row {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-meta-row strong { color: var(--text-muted); margin-right: 6px; }

.modal-threats {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 10px;
    padding: 14px;
    font-size: 14px;
}

.modal-threats ul { margin-top: 8px; padding-left: 18px; }
.modal-threats li { color: var(--danger-color); margin-bottom: 4px; }

.modal-links {
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 10px;
    padding: 14px;
    font-size: 14px;
}

.modal-links ul { margin-top: 8px; padding-left: 18px; }

.modal-body-text { font-size: 14px; color: var(--text-secondary); }
.modal-body-text p { margin-top: 6px; line-height: 1.7; }

/* =============================================================
   UNIFIED LOGIN PORTAL — User + Admin tabs
   ============================================================= */

#loginScreen {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* ── Left branding panel ─────────────────────────────────────── */
.login-left {
    width: 420px;
    flex-shrink: 0;
    background: linear-gradient(160deg, #0f1f3d 0%, #0f172a 60%);
    border-right: 1px solid rgba(99,102,241,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    top: -120px; left: -120px;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.login-left::after {
    content: '';
    position: absolute;
    bottom: -80px; right: -80px;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(139,92,246,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.login-brand {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-brand-icon {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #fff;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 32px rgba(99,102,241,0.35);
}

.login-brand h1 {
    font-size: 2.2rem; font-weight: 800;
    background: linear-gradient(135deg, #f1f5f9, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
}

.login-brand p {
    color: var(--text-muted); font-size: 0.9rem;
}

/* Feature list on left */
.login-features {
    display: flex; flex-direction: column; gap: 1.1rem;
    flex: 1;
}

.login-feature {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    transition: background 0.2s;
}

.login-feature:hover {
    background: rgba(99,102,241,0.07);
}

.feature-icon {
    width: 36px; height: 36px; flex-shrink: 0;
    background: rgba(99,102,241,0.15);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-color); font-size: 0.95rem;
}

.login-feature strong {
    display: block;
    font-size: 0.88rem; font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.login-feature span {
    font-size: 0.78rem; color: var(--text-muted);
}

.login-footer-note {
    font-size: 0.75rem; color: #475569;
    text-align: center; margin-top: 1.5rem;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ── Right forms panel ───────────────────────────────────────── */
.login-right {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem 2.25rem;
    width: 100%; max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

/* Portal header inside card */
.portal-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.portal-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.2));
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: var(--primary-color);
    margin: 0 auto 0.85rem;
}

.portal-header h2 {
    font-size: 1.4rem; font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.portal-header p {
    font-size: 0.85rem; color: var(--text-muted);
}

/* ── Role tabs ───────────────────────────────────────────────── */
.role-tabs {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 1.75rem;
    border: 1px solid var(--border-color);
}

.role-tab {
    display: flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 10px 0;
    border-radius: 9px;
    font-size: 0.88rem; font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
    border: none; background: none;
}

.role-tab i { font-size: 0.85rem; }

.role-tab.active {
    background: var(--bg-secondary);
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    border: 1px solid rgba(99,102,241,0.25);
}

.role-tab:hover:not(.active) {
    color: var(--text-secondary);
    background: rgba(255,255,255,0.03);
}

/* ── Login panels ────────────────────────────────────────────── */
.login-panel { display: none; }
.login-panel.active { display: block; }

.panel-desc {
    font-size: 0.85rem; color: var(--text-muted);
    line-height: 1.6; margin-bottom: 1.25rem;
    text-align: center;
}

/* User permissions list */
.user-perms {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin-bottom: 1.5rem;
}

.perm-item {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.8rem; color: var(--text-secondary);
    background: rgba(16,185,129,0.06);
    border: 1px solid rgba(16,185,129,0.12);
    border-radius: 8px;
    padding: 7px 10px;
}

.perm-item i { color: var(--success-color); font-size: 0.75rem; flex-shrink: 0; }

/* Google button */
.btn-google {
    display: flex; align-items: center; justify-content: center;
    gap: 12px;
    background: #ffffff; color: #1f2937;
    padding: 0.85rem 1.5rem;
    border-radius: 10px;
    font-size: 0.95rem; font-weight: 600;
    width: 100%; text-decoration: none;
    transition: box-shadow 0.2s, transform 0.2s;
    margin-bottom: 1rem;
    border: none; cursor: pointer;
}

.btn-google:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    transform: translateY(-2px);
}

/* Admin form */
.admin-form { margin-bottom: 1rem; }

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

.form-field label {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.78rem; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 7px;
}

.form-field label i { font-size: 0.72rem; }

.form-field input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.pass-wrap {
    position: relative;
}

.pass-wrap input { padding-right: 42px; }

.pass-toggle {
    position: absolute; right: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted); font-size: 0.85rem;
    background: none; border: none; cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}
.pass-toggle:hover { color: var(--text-primary); }

.admin-login-error {
    display: none;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.82rem; color: var(--danger-color);
    margin-bottom: 1rem;
    display: none; align-items: center; gap: 7px;
}

.admin-login-error.visible {
    display: flex;
}

.btn-admin-login {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border: none; border-radius: 10px;
    font-size: 0.95rem; font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}

.btn-admin-login:hover {
    opacity: 0.9; transform: translateY(-1px);
}

.btn-admin-login:disabled {
    opacity: 0.6; cursor: not-allowed; transform: none;
}

/* Login note at bottom of each panel */
.login-note {
    display: flex; align-items: center; justify-content: center;
    gap: 6px;
    font-size: 0.76rem; color: var(--text-muted);
    text-align: center; margin-top: 0.75rem;
}

.login-note code {
    background: var(--bg-tertiary);
    padding: 1px 5px; border-radius: 4px;
    font-size: 0.72rem; color: var(--text-secondary);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .login-card { padding: 1.5rem 1rem; }
}


/* =============================================================
   NOTIFICATION PANEL
   ============================================================= */

.notif-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 149;
}
.notif-overlay.open { display: block; }

.notif-panel {
    position: fixed; top: 0; right: -380px;
    width: 360px; height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 150;
    display: flex; flex-direction: column;
    transition: right .3s cubic-bezier(.4,0,.2,1);
    box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.notif-panel.open { right: 0; }

.notif-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.notif-header h3 {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}
.notif-header h3 i { color: var(--primary-color); }

.notif-clear-btn {
    font-size: 11px; color: var(--primary-color);
    background: none; border: none; cursor: pointer;
    padding: 4px 8px; border-radius: 5px;
    transition: background .2s;
}
.notif-clear-btn:hover { background: rgba(99,102,241,.1); }

.notif-close-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px 6px; font-size: 14px;
    border-radius: 5px; transition: color .2s;
}
.notif-close-btn:hover { color: var(--text-primary); }

.notif-list { flex: 1; overflow-y: auto; padding: 8px 0; }

.notif-loading {
    padding: 40px; text-align: center;
    color: var(--text-muted); font-size: 13px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 18px; transition: background .15s; cursor: pointer;
    border-left: 3px solid transparent;
}
.notif-item:hover { background: rgba(255,255,255,.03); }
.notif-item.unread { border-left-color: var(--primary-color); background: rgba(99,102,241,.04); }
.notif-item.danger  { border-left-color: var(--danger-color); }
.notif-item.suspicious { border-left-color: var(--warning-color); }

.notif-icon {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.notif-icon.danger  { background: rgba(239,68,68,.12); color: var(--danger-color); }
.notif-icon.suspicious { background: rgba(245,158,11,.12); color: var(--warning-color); }
.notif-icon.safe    { background: rgba(16,185,129,.12); color: var(--success-color); }

.notif-content { flex: 1; min-width: 0; }
.notif-title {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 3px;
}
.notif-msg {
    font-size: 11px; color: var(--text-muted); line-height: 1.4;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-time { font-size: 10px; color: #334155; margin-top: 4px; }

.notif-empty {
    padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.notif-empty i { font-size: 36px; margin-bottom: 12px; display: block; opacity: .3; }
.notif-empty p { font-size: 13px; }

/* =============================================================
   NOTIFICATION PANEL — SECTION STYLES
   ============================================================= */

.notif-section-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    margin-top: 4px;
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-secondary);
}

.notif-section-header.remark-header {
    color: #818cf8;
}

.notif-section-header.alert-header {
    color: var(--warning-color);
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
}

.notif-section-header i {
    font-size: 12px;
}

.notif-clear-inline {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 2px 8px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.notif-clear-inline:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.notif-empty-small {
    padding: 14px 18px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.notif-empty-small i {
    font-size: 13px;
    opacity: .5;
}

/* Remark notification item */
.notif-item.remark-item {
    border-left-color: #818cf8;
    background: rgba(129,140,248,.04);
}
.notif-item.remark-item:hover {
    background: rgba(129,140,248,.08);
}

.notif-icon.remark {
    background: rgba(129,140,248,.15);
    color: #818cf8;
}

.notif-remark-text {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.4;
    margin: 3px 0;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-meta {
    font-size: 10px;
    color: #334155;
    margin-top: 3px;
}

.notif-level-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: .4px;
    vertical-align: middle;
}
.notif-level-tag.danger     { background: rgba(239,68,68,.15);   color: var(--danger-color); }
.notif-level-tag.suspicious { background: rgba(245,158,11,.15);  color: var(--warning-color); }
.notif-level-tag.safe       { background: rgba(16,185,129,.15);  color: var(--success-color); }

/* =============================================================
   AI CHAT BOT
   ============================================================= */

.ai-chat-bubble {
    position: fixed; bottom: 24px; right: 24px;
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer; z-index: 140;
    box-shadow: 0 6px 24px rgba(99,102,241,.45);
    transition: transform .2s, box-shadow .2s;
    color: #fff;
}
.ai-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(99,102,241,.55);
}
.ai-chat-bubble i { font-size: 20px; }
.ai-bubble-label { font-size: 8px; font-weight: 700; letter-spacing: .5px; margin-top: -2px; }

.ai-chat-panel {
    position: fixed; bottom: 90px; right: 24px;
    width: 340px; height: 480px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    display: flex; flex-direction: column;
    z-index: 139;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    transform: scale(.9) translateY(20px);
    opacity: 0; pointer-events: none;
    transition: all .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
.ai-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1; pointer-events: all;
}

.ai-chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(139,92,246,.1));
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.ai-chat-title { display: flex; align-items: center; gap: 10px; }
.ai-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px; display: flex; align-items: center;
    justify-content: center; font-size: 15px; color: #fff;
}
.ai-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.ai-status {
    display: flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--success-color);
}
.ai-dot {
    width: 6px; height: 6px; background: var(--success-color);
    border-radius: 50%; animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.4} }

.ai-close-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 14px; padding: 4px;
    border-radius: 5px; transition: color .2s;
}
.ai-close-btn:hover { color: var(--text-primary); }

.ai-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}

.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.ai   { justify-content: flex-start; }

.ai-msg-bubble {
    max-width: 82%; padding: 10px 13px;
    border-radius: 14px; font-size: 13px; line-height: 1.5;
}
.ai-msg.user .ai-msg-bubble {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff; border-bottom-right-radius: 4px;
}
.ai-msg.ai .ai-msg-bubble {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary); border-bottom-left-radius: 4px;
}

.ai-typing .ai-msg-bubble {
    display: flex; gap: 4px; align-items: center; padding: 12px 16px;
}
.ai-typing .dot {
    width: 6px; height: 6px; background: var(--text-muted);
    border-radius: 50%; animation: typing-bounce .8s infinite;
}
.ai-typing .dot:nth-child(2) { animation-delay: .15s; }
.ai-typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

.ai-suggestions {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0;
}
.ai-suggest {
    background: rgba(99,102,241,.08);
    border: 1px solid rgba(99,102,241,.2);
    color: var(--primary-color);
    padding: 5px 10px; border-radius: 20px;
    font-size: 11px; cursor: pointer;
    transition: background .2s; white-space: nowrap;
}
.ai-suggest:hover { background: rgba(99,102,241,.15); }

.ai-input-row {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px; border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.ai-input {
    flex: 1; padding: 9px 13px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px; color: var(--text-primary);
    font-size: 13px; outline: none;
    transition: border .2s; font-family: inherit;
}
.ai-input:focus { border-color: var(--primary-color); }
.ai-send-btn {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none; border-radius: 50%;
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
    transition: opacity .2s, transform .2s;
}
.ai-send-btn:hover { opacity: .85; transform: scale(1.05); }
.ai-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* AI summarise button on email cards */
.btn-ai-summary {
    background: rgba(99,102,241,.1);
    border: 1px solid rgba(99,102,241,.25);
    color: var(--primary-color);
    padding: 4px 10px; border-radius: 6px;
    font-size: 11px; cursor: pointer;
    transition: background .2s; display: inline-flex;
    align-items: center; gap: 5px;
}
.btn-ai-summary:hover { background: rgba(99,102,241,.18); }

/* AI summary box inside email modal */
.ai-summary-box {
    background: rgba(99,102,241,.06);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: 10px; padding: 12px 14px;
    margin-bottom: 14px; font-size: 13px;
    line-height: 1.6; color: var(--text-secondary);
}
.ai-summary-box .ai-summary-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; color: var(--primary-color);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}

@media (max-width: 768px) {
    .ai-chat-panel { width: calc(100vw - 32px); right: 16px; bottom: 80px; }
    .notif-panel   { width: 100%; }
}

/* ── Scan toggle status bar ──────────────────────────────────── */
.btn-scan-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(15,23,42,.04);
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s ease;
    text-align: left;
}
.btn-scan-toggle:hover {
    background: rgba(99,102,241,.08);
    border-color: rgba(99,102,241,.3);
}
.btn-scan-toggle.active {
    background: rgba(99,102,241,.10);
    border-color: rgba(99,102,241,.35);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}
.scan-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.scan-status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.scan-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.scan-status-text  { font-size: 11px; font-weight: 600; }
.scan-status-sep   { color: var(--text-muted); font-size: 13px; }
.scan-toggle-arrow {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    transition: transform .2s ease;
    display: inline-block;
}

/* ── Inline scan detail panel ────────────────────────────────── */
.scan-inline-panel {
    padding: 12px;
    background: rgba(15,23,42,.05);
    border: 1px solid rgba(99,102,241,.25);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: siSlideIn .18s ease;
}
@keyframes siSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.si-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.si-row + .si-row {
    padding-top: 8px;
    border-top: 1px solid rgba(148,163,184,.1);
}
.si-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    min-width: 155px;
    padding-top: 3px;
    flex-shrink: 0;
}
.si-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.si-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid;
    background: transparent;
    white-space: nowrap;
    cursor: default;
}
.si-note {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}
@media (max-width: 768px) {
    .si-row   { flex-direction: column; gap: 5px; }
    .si-label { min-width: unset; }
    .scan-status-text { display: none; }
}

/* ===== ADMIN OVERRIDE / REMARK — USER PORTAL ===== */

/* Badge shown next to severity pill in threat cards */
.admin-override-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.admin-override-badge i {
    font-size: 11px;
    color: #818cf8;
}

/* Remark block in threat cards */
.admin-remark-block {
    margin: 0 0 20px;
    padding: 14px 16px;
    background: rgba(99, 102, 241, 0.07);
    border-left: 3px solid #6366f1;
    border-radius: 0 8px 8px 0;
}

.admin-remark-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #818cf8;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-remark-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Override chip inside email modal */
.modal-override-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
    padding: 3px 9px;
    border-radius: 20px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

.modal-override-chip i { font-size: 10px; }

/* Admin remark block inside email modal */
.modal-admin-remark {
    margin: 0 0 16px;
    padding: 14px 18px;
    background: rgba(99, 102, 241, 0.07);
    border-left: 3px solid #6366f1;
    border-radius: 0 8px 8px 0;
}

.modal-admin-remark-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #818cf8;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-admin-remark p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}
