/* ═══════════════════════════════════════════════
   Nei.io - Private Markets Platform
   Main Stylesheet
   ═══════════════════════════════════════════════ */

/* ── 1. CSS Custom Properties ── */
:root {
    /* Brand colors */
    --brand-primary: #4D84F5;
    --brand-primary-hover: #3a6fd4;
    --brand-primary-light: #e8f0fe;
    --brand-primary-bg: rgba(77, 132, 245, 0.08);
    --brand-secondary: #6c63ff;
    --brand-accent: #00c9a7;

    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fc;
    --bg-tertiary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-hover: #f5f7fa;
    --bg-input: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a7a;
    --text-muted: #8e8ea0;
    --border-color: #e2e5ea;
    --border-light: #f0f2f5;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);

    /* Status colors */
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    /* Layout */
    --nav-height: 64px;
    --container-max: 1280px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ── 2. Dark Theme ── */
[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-tertiary: #1e2030;
    --bg-card: #1a1c2e;
    --bg-hover: #252840;
    --bg-input: #1e2030;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6e6e88;
    --border-color: #2a2c40;
    --border-light: #1e2030;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
    --brand-primary-light: rgba(77, 132, 245, 0.15);
    --brand-primary-bg: rgba(77, 132, 245, 0.1);
}

/* ── 3. Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover {
    color: var(--brand-primary-hover);
}

img { max-width: 100%; }

/* ── 4. Layout ── */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
}

.main-content {
    flex: 1;
    padding: 24px 0;
    min-height: calc(100vh - var(--nav-height) - 60px);
}

/* ── 5. Navbar ── */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.navbar-public {
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    position: absolute;
    width: 100%;
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 100%;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--brand-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}
.nav-brand i {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.nav-link {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-link.active {
    background: var(--brand-primary-bg);
    color: var(--brand-primary);
}
.nav-link i {
    font-size: 0.85rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

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

.user-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-name i {
    font-size: 1.1rem;
    color: var(--brand-primary);
}

.msg-badge {
    background: var(--color-danger);
    color: white;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: all 0.15s;
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── 6. Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.2;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font-sans);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ── 7. Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    overflow: hidden;
}
.card:has(.ss-wrapper) {
    overflow: visible;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-header h2 i, .card-header h3 i {
    color: var(--brand-primary);
    font-size: 0.9rem;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}

/* ── 8. Tables ── */
.table-responsive {
    overflow-x: auto;
}

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

.table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    color: var(--text-primary);
}

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

.table-sm td, .table-sm th {
    padding: 8px 12px;
}

.clickable-row {
    cursor: pointer;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-style: italic;
}

/* ── 9. Forms ── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-full {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea,
.form-input,
.form-select,
.form-textarea {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(77, 132, 245, 0.1);
}

.form-select-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group {
    flex: 1;
}

.inline-form {
    display: inline;
}

/* ── 10. Page Header ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.back-link {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.back-link:hover {
    color: var(--brand-primary);
}

/* ── 11. Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--brand-primary);
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── 12. Pipeline ── */
.pipeline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px;
    overflow-x: auto;
}

.pipeline-stage {
    text-align: center;
    min-width: 80px;
}

.pipeline-count {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0 auto 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.pipeline-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.pipeline-arrow {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.pipeline-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px;
    overflow-x: auto;
    flex-wrap: wrap;
}

.pipeline-pill-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    transition: transform 0.15s;
}

.pipeline-pill-item:hover {
    transform: translateY(-2px);
}

.pipeline-pill-item.active .stage-badge {
    outline: 2px solid var(--text-primary);
    outline-offset: 1px;
}

.pipeline-pill-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── 13. Badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* A count badge that sits in a button toolbar — matches .btn-sm height */
.badge-control {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 0.8rem;
    line-height: 1.2;
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-buyer { background: #dbeafe; color: #1e40af; }
.role-seller { background: #d1fae5; color: #065f46; }
.role-admin_viewer { background: #ede9fe; color: #5b21b6; }

[data-theme="dark"] .role-admin { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
[data-theme="dark"] .role-buyer { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
[data-theme="dark"] .role-seller { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
[data-theme="dark"] .role-admin_viewer { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

.stage-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.stage-draft { background: #f1f5f9; color: #64748b; border: 1px dashed #94a3b8; }
.stage-intake { background: #e0f2fe; color: #0369a1; }
.stage-review { background: #fef3c7; color: #92400e; }
.stage-pricing { background: #fce7f3; color: #9d174d; }
.stage-matching { background: #e0e7ff; color: #3730a3; }
.stage-negotiation { background: #fef9c3; color: #854d0e; }
.stage-dd { background: #f3e8ff; color: #6b21a8; }
.stage-compliance { background: #fed7aa; color: #9a3412; }
.stage-closing { background: #ccfbf1; color: #115e59; }
.stage-closed { background: #d1fae5; color: #065f46; }
.stage-cancelled { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .stage-draft { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px dashed #475569; }
[data-theme="dark"] .stage-intake { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
[data-theme="dark"] .stage-review { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
[data-theme="dark"] .stage-pricing { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
[data-theme="dark"] .stage-matching { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
[data-theme="dark"] .stage-negotiation { background: rgba(234, 179, 8, 0.15); color: #facc15; }
[data-theme="dark"] .stage-dd { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
[data-theme="dark"] .stage-compliance { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
[data-theme="dark"] .stage-closing { background: rgba(20, 184, 166, 0.15); color: #2dd4bf; }
[data-theme="dark"] .stage-closed { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
[data-theme="dark"] .stage-cancelled { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.score-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-interested { background: #d1fae5; color: #065f46; }
.badge-passed { background: #fee2e2; color: #991b1b; }
.badge-in_progress { background: #e0e7ff; color: #3730a3; }
.badge-closed { background: #d1fae5; color: #065f46; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* ── 14. Detail Page ── */
.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.info-item label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.info-item span {
    font-size: 0.95rem;
    font-weight: 500;
}

.info-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.info-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.info-description {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}
.info-description label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
}
.info-description p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ── 15. Stage Form ── */
.stage-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ── 16. Documents ── */
.doc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.doc-icon {
    color: var(--brand-primary);
    font-size: 1.2rem;
}

.doc-info {
    display: flex;
    flex-direction: column;
}
.doc-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upload-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.upload-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── 17. Notes ── */
.note-item {
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.note-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.note-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.note-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.note-actions {
    margin-top: 8px;
}

.note-form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.note-form-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.note-form-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
}
.note-visibility {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 500;
}
.note-visibility.private {
    background: var(--bg-secondary);
    color: var(--text-muted);
}
.note-visibility.public {
    background: rgba(52, 152, 219, 0.12);
    color: #3498db;
}
.visibility-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    user-select: none;
}
.visibility-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.visibility-toggle-sm {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.visibility-toggle-sm input[type="checkbox"] {
    display: none;
}
.visibility-toggle-sm:hover {
    color: var(--text-primary);
}

/* ── 18. Messages ── */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.message-item {
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
}
.message-item.unread {
    border-left: 3px solid var(--brand-primary);
    background: var(--brand-primary-bg);
}

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

.message-to {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.message-subject {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.message-body {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.message-context {
    margin-top: 8px;
    font-size: 0.8rem;
}

.message-form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* ── 19. Activity Log ── */
.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-primary);
    margin-top: 6px;
    flex-shrink: 0;
}

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

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* ── 20. Filter Bar ── */
.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all 0.15s;
}
.filter-chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.filter-chip.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

/* ── 21. Cards Grid ── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.mandate-card .card-body {
    padding: 16px 20px;
}

.mandate-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mandate-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}
.mandate-item label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
}
.mandate-item span {
    font-size: 0.85rem;
    text-align: right;
}

/* ── 22. Admin ── */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.role-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pipeline-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.pipeline-count-inline {
    font-weight: 600;
    font-size: 1.1rem;
}

/* ── 23. Flash Messages ── */
.flash-container {
    max-width: var(--container-max);
    margin: 12px auto;
    padding: 0 24px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    animation: flashIn 0.2s ease;
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

[data-theme="dark"] .flash-success { background: rgba(34, 197, 94, 0.15); color: #4ade80; border-color: rgba(34, 197, 94, 0.3); }
[data-theme="dark"] .flash-error { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
[data-theme="dark"] .flash-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); }

.flash-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── 24. Auth Pages ── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 60px);
    padding: 40px 24px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo {
    font-size: 2.5rem;
    color: var(--brand-primary);
    margin-bottom: 16px;
}
.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-demo {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.demo-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    margin-bottom: 12px;
}

.demo-accounts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.demo-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    color: var(--text-secondary);
    transition: all 0.15s;
    font-family: var(--font-sans);
    display: flex;
    align-items: center;
    gap: 8px;
}
.demo-btn:hover {
    background: var(--bg-hover);
    border-color: var(--brand-primary);
}

/* ── 25. Hero Section ── */
.hero {
    position: relative;
    min-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.hero-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.hero-particles {
    width: 100%;
    height: 100%;
}
.hero-particles canvas {
    width: 100%;
    height: 100%;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 800px;
    padding: 0 24px;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto 40px;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 40px;
}

.stat-item {
    text-align: center;
}
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.2rem;
    color: var(--brand-primary);
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 2px;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.hero-cta {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ── 26. Features Section ── */
.features {
    padding: 80px 0;
    background: var(--bg-primary);
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 48px;
    letter-spacing: -0.5px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px;
    text-align: center;
    transition: all 0.2s;
}
.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-primary);
}

.feature-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.5rem;
    color: var(--brand-primary);
}

.feature-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── 27. About / Steps Section ── */
.about {
    padding: 80px 0;
    background: var(--bg-secondary);
}

.steps {
    display: flex;
    gap: 40px;
    justify-content: center;
    flex-wrap: wrap;
}

.step {
    text-align: center;
    max-width: 280px;
}

.step-number {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 auto 16px;
}

.step h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.step p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ── 28. Footer ── */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 16px 0;
}

.footer-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── 29. Empty State (Large) ── */
.empty-state-large {
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
}
.empty-state-large i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.empty-state-large h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}
.empty-state-large p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ── 30. Marketplace (Buy Page) ── */
.market-page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 28px 0;
    margin: -24px 0 24px;  /* pull up into main-content padding so it sits flush under navbar */
}
.market-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.market-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.market-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

.market-tabs {
    display: inline-flex;
    gap: 0;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-sm);
}
.market-tab {
    padding: 10px 24px;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    white-space: nowrap;
}
.market-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.market-tab.active {
    color: var(--brand-primary);
    background: var(--brand-primary-light);
    font-weight: 600;
}

.market-filters {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
}
.filter-search {
    position: relative;
    margin-bottom: 12px;
}
.filter-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}
.filter-search input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.15s;
}
.filter-search input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(77, 132, 245, 0.1);
}
.filter-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 160px;
}
.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    background: var(--bg-input);
    color: var(--text-primary);
}
.range-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.range-display input[type="range"] {
    width: 100%;
    accent-color: var(--brand-primary);
}
#range-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ── 31. Deal Cards Grid ── */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.deal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    overflow: hidden;
}
.deal-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--brand-primary);
    transform: translateY(-2px);
}
.deal-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.deal-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.deal-card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}
.deal-card-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.deal-sector-badge {
    margin-bottom: 10px;
    align-self: flex-start;
}
.deal-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
    flex: 1;
}
.deal-card-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.metric-label i {
    font-size: 0.7rem;
}
.metric-value {
    font-size: 0.95rem;
    font-weight: 600;
}
.metric-value-lg {
    font-size: 1.15rem;
    color: var(--brand-primary);
}
.deal-card-valuation {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    margin-bottom: 12px;
}
.deal-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.deal-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
}
.deal-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}
.deal-card-btn {
    border-radius: 0;
    margin-top: auto;
}
.match-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: #fef3c7;
    color: #92400e;
    white-space: nowrap;
}
[data-theme="dark"] .match-badge {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}
.market-no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* ── 32. Interest Heart Button ── */
.interest-heart-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 4px;
    transition: all 0.15s;
    line-height: 1;
}
.interest-heart-btn:hover {
    color: #ef4444;
    transform: scale(1.15);
}
.interest-heart-btn.interested {
    color: #ef4444;
}

/* ── 33. Deal Detail Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.2s;
}
.modal-overlay.active .modal-content {
    transform: translateY(0);
}
.modal-content.modal-lg {
    max-width: 800px;
}
.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-header h3 i {
    color: var(--brand-primary);
    font-size: 1rem;
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    z-index: 1;
}
.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 56px 16px 24px;  /* extra right padding for close button */
    gap: 16px;
}
.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-header h2 i {
    color: var(--brand-primary);
    font-size: 1.1rem;
}
.modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-top: 8px;
}
.modal-tags-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.modal-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.modal-body {
    padding: 0 24px 24px;
}
.modal-section-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.modal-section {
    margin-bottom: 16px;
}
.modal-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-section h3 i {
    color: var(--brand-primary);
    font-size: 0.85rem;
}
.modal-metric-highlight {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.metric-value-big {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand-primary);
}
.modal-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
.modal-detail-row:last-child {
    border-bottom: none;
}
.modal-detail-row span:first-child {
    color: var(--text-muted);
}
.modal-detail-row span:last-child {
    font-weight: 500;
}
.modal-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}
.modal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}
.modal-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.modal-cta span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.modal-cta span i {
    color: var(--brand-primary);
}

/* ── 34. Sell Page ── */
.sell-signin-prompt {
    text-align: center;
    padding: 80px 24px;
    max-width: 480px;
    margin: 0 auto;
}
.sell-signin-prompt i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.sell-signin-prompt h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.sell-signin-prompt p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}
.sell-form-container {
    max-width: 800px;
    margin: 0 auto;
}
.form-section-title {
    padding-top: 8px;
    margin-bottom: -4px;
}
.form-section-title h4 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}
.form-section-title h4 i {
    color: var(--brand-primary);
    font-size: 0.85rem;
}
.form-section-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── 35. Message Thread View ── */
.msg-filter-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}
.msg-filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    width: 100%;
}
.msg-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}
.msg-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    position: relative;
}
.msg-received {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.msg-sent {
    align-self: flex-end;
    background: var(--brand-primary-light);
    border: 1px solid var(--brand-primary);
    border-color: rgba(77, 132, 245, 0.2);
}
.msg-bubble-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.msg-bubble-header strong {
    color: var(--text-primary);
}
.msg-arrow {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.msg-bubble-time {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.msg-bubble-subject {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.msg-bubble-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* ── 35a2. Pinned Deal in Conversation ── */
.conv-pinned-deal {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--brand-primary);
    background: var(--brand-primary-bg);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: background 0.15s;
}
.conv-pinned-deal:hover {
    background: var(--brand-primary-light);
}
.conv-pinned-deal i {
    font-size: 0.7rem;
}
.conv-pin-deal-bar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

/* ── 35b. Conversation List (page) ── */
.convo-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.convo-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
}
.convo-item:hover {
    background: var(--bg-secondary);
}
.convo-avatars {
    display: flex;
    gap: 0;
    font-size: 1.6rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.convo-avatars i:last-child {
    margin-left: -8px;
    color: var(--text-secondary);
}
.convo-info {
    flex: 1;
    min-width: 0;
}
.convo-names {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.convo-names strong {
    font-size: 0.9rem;
}
.convo-separator {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.convo-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.convo-subject {
    font-weight: 600;
    color: var(--text-primary);
}
.convo-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.convo-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── 35c. Chat Widget (bottom-right) ── */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}
.chat-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(77, 132, 245, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(77, 132, 245, 0.45);
}
.chat-fab .fa-times { display: none; }
.chat-fab.active .fa-comment { display: none; }
.chat-fab.active .fa-times { display: inline; }
.chat-panel {
    width: 400px;
    max-height: 680px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.chat-panel.open {
    display: flex;
}
.chat-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.chat-panel-header h3 {
    font-size: 0.95rem;
    margin: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-panel-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.chat-panel-header button:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}
.chat-panel-body {
    flex: 1;
    overflow-y: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
/* Conversation list inside chat panel */
.chat-convo-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
}
.chat-convo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}
.chat-convo-item:hover {
    background: var(--bg-secondary);
}
.chat-convo-item:last-child {
    border-bottom: none;
}
.chat-convo-avatar {
    font-size: 1.5rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.chat-convo-info {
    flex: 1;
    min-width: 0;
}
.chat-convo-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-convo-snippet {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.chat-convo-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: right;
}
.chat-convo-meta .badge {
    font-size: 0.65rem;
    margin-top: 4px;
}
/* Thread view inside chat panel */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    min-height: 100px;
    overflow-y: auto;
    flex: 1;
}
.chat-thread .msg-bubble {
    max-width: 80%;
    padding: 8px 12px;
    font-size: 0.85rem;
}
.chat-thread .msg-bubble-header {
    font-size: 0.72rem;
}
.chat-thread .msg-bubble-body {
    font-size: 0.85rem;
    line-height: 1.5;
}
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.85rem;
}
/* Compose bar inside chat panel */
.chat-compose {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.chat-compose input,
.chat-compose textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 0.85rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: none;
    font-family: inherit;
}
.chat-compose button {
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.chat-compose button:hover {
    background: var(--brand-primary-hover);
}
/* New message form inside chat panel */
.chat-new-msg {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
}
.chat-new-msg label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.chat-new-msg select,
.chat-new-msg input,
.chat-new-msg textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 0.85rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}
.chat-new-msg textarea {
    resize: none;
    min-height: 60px;
}
.chat-new-msg button {
    align-self: flex-end;
}
.chat-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
/* Search bar in chat */
.chat-search {
    padding: 10px 14px 6px;
    flex-shrink: 0;
}
.chat-search input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 0.82rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}
.chat-search input::placeholder {
    color: var(--text-muted);
}
/* Deal filter in thread */
.chat-deal-filter {
    padding: 8px 14px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}
.chat-deal-filter select {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    font-size: 0.8rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}
/* Recipient picker in new message */
.chat-recipient-list {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    display: none;
}
.chat-recipient-option {
    padding: 8px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.chat-recipient-option:last-child {
    border-bottom: none;
}
.chat-recipient-option:hover {
    background: var(--bg-secondary);
}
@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 32px);
        max-height: 70vh;
        right: 0;
    }
    .chat-widget {
        right: 16px;
        bottom: 16px;
    }
}

/* ── 35d. Document Sign-offs ── */
.signoff-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.signoff-item:last-child {
    border-bottom: none;
}
.signoff-info {
    flex: 1;
    min-width: 0;
}
.signoff-info strong {
    display: block;
    font-size: 0.9rem;
}
.signoff-actions {
    flex-shrink: 0;
}
.signoff-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.signoff-approved {
    background: rgba(46, 204, 113, 0.15);
    color: #27ae60;
}
.signoff-rejected {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}
.signoff-requested {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}
.signoff-pending {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* ── 35e. Conversation Requests ── */
.conv-request-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
}
.conv-request-status i {
    font-size: 1.5rem;
}
.conv-request-status p {
    margin: 0;
}
.conv-request-status.pending {
    background: rgba(243, 156, 18, 0.1);
    color: #f39c12;
}
.conv-request-status.accepted {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
}
.conv-request-status.declined {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}
.conv-request-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.conv-request-item:last-child {
    border-bottom: none;
}
.conv-request-info {
    flex: 1;
    min-width: 0;
}
.conv-request-message {
    margin: 6px 0 4px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.conv-request-actions {
    flex-shrink: 0;
    padding-top: 4px;
}

/* ── 36. Searchable Select ── */
.ss-wrapper {
    position: relative;
    z-index: 100;
}
.ss-input {
    width: 100%;
    cursor: text;
}
.ss-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    z-index: 1;
}
.ss-clear:hover {
    color: var(--text-primary);
}
.ss-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}
.ss-dropdown.ss-open {
    display: block;
}
.ss-group {
    padding: 6px 14px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}
.ss-group:first-child {
    border-top: none;
}
.ss-option {
    padding: 8px 14px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.1s;
}
.ss-option:hover {
    background: var(--bg-hover);
}
.ss-option.ss-selected {
    background: var(--brand-primary-bg);
    color: var(--brand-primary);
    font-weight: 500;
}
.ss-empty {
    padding: 12px 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── 37. Stage Tabs ── */
.stage-tabs {
    display: flex;
    gap: 2px;
    padding: 0 16px 12px;
    overflow-x: auto;
    flex-wrap: wrap;
}
.stage-tab {
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    border: 1px solid transparent;
}
.stage-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.stage-tab.active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}
.stage-tab.current:not(.active) {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
.stage-tab.locked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto;
}
.stage-tab.locked:hover {
    background: transparent;
    color: var(--text-muted);
}

/* ── 37b. Dual Sign-off Checkmarks ── */
.dual-signoff {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.signoff-check {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--radius-full);
}
.signoff-check.signed {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}
.signoff-check.pending {
    color: var(--text-muted);
    background: var(--bg-secondary);
}
.signoff-check i {
    font-size: 0.7rem;
}

/* ── 37c. Stage Warning ── */
.stage-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    font-size: 0.85rem;
    line-height: 1.5;
}
.stage-warning i {
    margin-top: 2px;
    flex-shrink: 0;
}

/* ── 37d. Interest Detail List ── */
.interest-detail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.interest-detail-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
.interest-detail-item:last-child {
    border-bottom: none;
}
.interest-detail-item i {
    font-size: 1.3rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.interest-detail-item div {
    flex: 1;
}
.interest-user-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.interest-user-chip {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ── 37e. Note Mention Tag ── */
.note-mention {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--brand-primary);
    background: var(--brand-primary-bg);
    padding: 1px 7px;
    border-radius: var(--radius-full);
    margin-left: 4px;
}
.note-mention i {
    font-size: 0.65rem;
}
.note-tag-select {
    font-size: 0.82rem;
    padding: 5px 8px;
    max-width: 200px;
}

/* ── 37f. Stage Group ── */
.stage-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.stage-group .card {
    margin-bottom: 0;
}
.stage-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--brand-primary);
    padding: 4px 0 0;
}
.stage-group-header i {
    font-size: 0.8rem;
}

/* ── 37g. Card Highlight ── */
.card-highlight {
    border: 1px solid var(--color-warning);
    background: rgba(245, 158, 11, 0.03);
}
.card-highlight .card-header h2 {
    color: #d97706;
}

/* ── 38. Table Enhancement (filter + sort) ── */
.table-filter {
    position: relative;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}
.table-filter > i.fa-search {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}
.table-filter-input {
    flex: 1;
    padding: 10px 16px 10px 38px;
    border: none;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: background 0.15s;
}
.table-filter-input:focus {
    background: var(--bg-input);
    box-shadow: inset 0 -2px 0 var(--brand-primary);
}
.table-filter-input::placeholder {
    color: var(--text-muted);
}
.table-reset-btn {
    flex-shrink: 0;
    margin-right: 8px;
    font-size: 0.78rem;
    padding: 4px 10px;
    color: var(--text-secondary);
    border-color: var(--border-color);
    white-space: nowrap;
}
.table-reset-btn:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
}
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.sortable-th:hover {
    color: var(--brand-primary);
}
.sort-arrow {
    color: var(--text-muted);
    font-size: 0.65rem;
    margin-left: 4px;
    vertical-align: middle;
}
.sortable-th:hover .sort-arrow,
.sortable-th.sort-asc .sort-arrow,
.sortable-th.sort-desc .sort-arrow {
    color: var(--brand-primary);
}
.table-no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 0.9rem;
    font-style: italic;
}

.table-pager {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
}

.table-pager .pager-btn {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* When the pager is hoisted into a card-header toolbar (via data-pager-target),
   drop the vertical padding so its button lines up with the other controls. */
.card-header .table-pager {
    padding: 0;
}

/* ── 39. Utilities ── */
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── 35. Responsive ── */
@media (max-width: 768px) {
    .hero-title { font-size: 2.2rem; }
    .hero-stats { flex-direction: column; gap: 24px; }
    .hero-cta { flex-direction: column; align-items: center; }
    .nav-links { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .cards-grid { grid-template-columns: 1fr; }
    .pipeline { flex-wrap: wrap; justify-content: center; }
    .upload-row { flex-direction: column; align-items: stretch; }
    .admin-grid { grid-template-columns: 1fr; }
    .market-grid { grid-template-columns: 1fr; }
    .filter-row { flex-direction: column; }
    .modal-section-row { grid-template-columns: 1fr; }
    .modal-content { max-height: 90vh; }
    .modal-header { flex-direction: column; }
    .modal-tags-right { align-items: flex-start; }
    .modal-cta { flex-direction: column; align-items: stretch; text-align: center; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px; }
}
