/* ============================================
   VIAM DESIGN SYSTEM - Core Tokens
   From Official Viam Brand Guidelines
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Roboto:wght@300;400;500;700&display=swap');

:root {
    /* ─────────────────────────────
       CORE PALETTE (Official Viam)
       ───────────────────────────── */
    --viam-helios: #EAFF99;        /* Primary accent - signal/accent */
    --viam-carbon: #040D0D;        /* Darkest, primary dark ground */
    --viam-teal: #152C2E;          /* Deep teal, secondary dark */
    --viam-steel: #728C90;         /* Mid gray, secondary text, captions */
    --viam-overcast: #CFD6D7;      /* Light neutral, tertiary bg */
    --viam-offwhite: #FCFCF4;      /* Warm off-white, light fg on dark */
    --viam-white: #FFFFFF;

    /* ─────────────────────────────
       SEMANTIC - LIGHT THEME
       ───────────────────────────── */
    --bg: var(--viam-white);
    --bg-2: var(--viam-offwhite);
    --bg-3: var(--viam-overcast);
    --bg-invert: var(--viam-carbon);

    --fg-1: var(--viam-carbon);    /* Primary text */
    --fg-2: var(--viam-steel);     /* Secondary / captions */
    --fg-3: var(--viam-overcast);  /* Tertiary */
    --fg-invert: var(--viam-offwhite);

    --accent: var(--viam-helios);
    --accent-fg: var(--viam-carbon); /* Text on Helios */

    --border: var(--viam-carbon);
    --border-subtle: var(--viam-overcast);

    /* ─────────────────────────────
       TYPOGRAPHY
       ───────────────────────────── */
    --font-display: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Space Mono', 'SF Mono', Consolas, monospace;
    --font-functional: 'Roboto', system-ui, sans-serif;

    --fw-regular: 400;
    --fw-medium: 500;
    --fw-bold: 700;

    --tracking-display: -0.05em;
    --tracking-body: 0;

    /* UI Type Scale */
    --fs-ui-lg: 18px;
    --fs-ui: 16px;
    --fs-ui-sm: 14px;
    --fs-ui-xs: 12px;

    /* ─────────────────────────────
       SPACING - 30px baseline
       ───────────────────────────── */
    --space-1: 6px;
    --space-2: 12px;
    --space-3: 18px;
    --space-4: 24px;
    --space-5: 30px;
    --space-6: 60px;

    /* ─────────────────────────────
       RADII
       ───────────────────────────── */
    --r-sm: 4px;
    --r-md: 12px;
    --r-lg: 15px;
    --r-pill: 999px;

    /* ─────────────────────────────
       ELEVATION - Hairlines, not shadows
       ───────────────────────────── */
    --shadow-none: none;
    --shadow-hairline: 0 0 0 1px var(--viam-carbon);
    --shadow-hairline-light: 0 0 0 1px var(--viam-overcast);
    --shadow-card: 0 1px 2px rgba(4,13,13,0.04), 0 2px 8px rgba(4,13,13,0.04);
    --shadow-float: 0 12px 32px rgba(4,13,13,0.12), 0 2px 8px rgba(4,13,13,0.06);

    /* ─────────────────────────────
       MOTION
       ───────────────────────────── */
    --ease-precise: cubic-bezier(0.2, 0, 0, 1);
    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 120ms;
    --dur-med: 200ms;
    --dur-slow: 400ms;

    /* Status colors (semantic) */
    --status-success: #22c55e;
    --status-warning: #eab308;
    --status-danger: #ef4444;
}

/* ============================================
   RESET & BASE
   ============================================ */

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

::selection {
    background: var(--viam-helios);
    color: var(--viam-carbon);
}

body {
    font-family: var(--font-body);
    font-weight: var(--fw-regular);
    font-size: var(--fs-ui);
    line-height: 1.5;
    color: var(--fg-1);
    background: var(--bg);
    min-height: 100vh;
    padding: 0;
}

/* ============================================
   CONTAINER
   ============================================ */

.container {
    max-width: 100%;
    margin: 0;
    background: var(--bg);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */

header {
    background: var(--viam-carbon);
    color: var(--fg-invert);
    padding: var(--space-5) var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    border-bottom: 1px solid var(--viam-teal);
}

.logo-container {
    flex-shrink: 0;
}

.logo-container img {
    height: 40px;
    width: auto;
}

.header-content {
    flex: 1;
}

header h1 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: var(--fw-medium);
    letter-spacing: var(--tracking-display);
    margin-bottom: var(--space-1);
}

.subtitle {
    font-size: var(--fs-ui-sm);
    color: var(--viam-steel);
    font-weight: var(--fw-regular);
}

.internal-badge {
    background: var(--viam-helios);
    color: var(--viam-carbon);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-ui-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   TAB NAVIGATION
   ============================================ */

.tab-navigation {
    display: flex;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    font-family: var(--font-display);
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
    color: var(--fg-2);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-standard);
    position: relative;
}

.tab-btn:hover {
    background: var(--bg);
    color: var(--fg-1);
}

.tab-btn.active {
    color: var(--fg-1);
    background: var(--bg);
}

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

/* ============================================
   TAB CONTENT
   ============================================ */

.tab-content {
    display: none;
}

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

/* ============================================
   MAIN CONTENT
   ============================================ */

main {
    padding: var(--space-6);
}

section {
    margin-bottom: var(--space-6);
}

h2 {
    font-family: var(--font-display);
    font-weight: var(--fw-medium);
    font-size: 20px;
    letter-spacing: var(--tracking-display);
    color: var(--fg-1);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
}

/* ============================================
   BUTTONS - Viam Style
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font-display);
    font-size: var(--fs-ui-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--dur-fast) var(--ease-standard);
    background: var(--bg);
    color: var(--fg-1);
}

.btn:hover {
    background: var(--bg-2);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary:disabled {
    opacity: 0.7;
}

.btn-sm {
    padding: var(--space-1) var(--space-2);
    font-size: var(--fs-ui-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-5);
    font-size: var(--fs-ui);
}

.btn-primary {
    background: var(--viam-helios);
    color: var(--viam-carbon);
    border-color: var(--viam-helios);
}

.btn-primary:hover:not(:disabled) {
    background: #d4eb8a;
    border-color: #d4eb8a;
}

.btn-secondary {
    background: var(--viam-carbon);
    color: var(--fg-invert);
    border-color: var(--viam-carbon);
}

.btn-secondary:hover {
    background: var(--viam-teal);
    border-color: var(--viam-teal);
}

.btn-success {
    background: var(--status-success);
    color: white;
    border-color: var(--status-success);
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
    border-color: #16a34a;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg-1);
}

.btn-outline:hover {
    background: var(--bg-2);
}

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

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

/* ============================================
   ACTION BUTTONS BAR
   ============================================ */

.action-buttons {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    background: var(--bg-2);
    border-radius: var(--r-md);
    border: 1px solid var(--border-subtle);
}

/* ============================================
   FILE INPUT
   ============================================ */

.file-input-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.file-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.file-input-wrapper label {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
    font-size: var(--fs-ui-sm);
}

.file-input-wrapper input[type="file"] {
    padding: var(--space-3);
    border: 1px dashed var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-2);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-standard);
}

.file-input-wrapper input[type="file"]:hover {
    border-color: var(--viam-helios);
    background: var(--bg);
}

.file-name {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    font-style: italic;
}

/* ============================================
   BUTTON GROUP
   ============================================ */

.button-group {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* ============================================
   PROGRESS SECTION
   ============================================ */

.progress-section {
    background: var(--bg-2);
    padding: var(--space-5);
    border-radius: var(--r-md);
    text-align: center;
    border: 1px solid var(--border-subtle);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-subtle);
    border-radius: var(--r-sm);
    overflow: hidden;
    margin: var(--space-4) 0;
}

.progress-fill {
    height: 100%;
    background: var(--viam-helios);
    width: 0%;
    transition: width var(--dur-med) var(--ease-standard);
    border-radius: var(--r-sm);
}

.progress-text {
    font-size: var(--fs-ui);
    color: var(--fg-1);
    font-weight: var(--fw-medium);
}

/* ============================================
   RESULTS SECTION
   ============================================ */

.results-section {
    background: var(--bg-2);
    padding: var(--space-5);
    border-radius: var(--r-md);
    border: 1px solid var(--border-subtle);
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.summary-card {
    background: var(--bg);
    padding: var(--space-4);
    border-radius: var(--r-md);
    text-align: center;
    box-shadow: var(--shadow-card);
    border-left: 3px solid var(--viam-helios);
}

.summary-card.success {
    border-left-color: var(--status-success);
}

.summary-card.failed {
    border-left-color: var(--status-danger);
}

.summary-label {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
    font-weight: var(--fw-bold);
}

.summary-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: var(--fw-bold);
    color: var(--fg-1);
}

.download-buttons {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================
   ERROR SECTION
   ============================================ */

.error-section {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--r-md);
    padding: var(--space-5);
    text-align: center;
}

.error-section h2 {
    color: var(--status-danger);
    border-bottom: none;
}

.error-message {
    background: var(--bg);
    padding: var(--space-4);
    border-radius: var(--r-sm);
    margin: var(--space-4) 0;
    color: var(--status-danger);
    font-weight: var(--fw-medium);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    background: var(--viam-carbon);
    padding: var(--space-4);
    text-align: center;
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
    border-top: 1px solid var(--viam-teal);
}

footer a {
    color: var(--viam-helios);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        padding: var(--space-4);
    }

    header h1 {
        font-size: 20px;
    }

    main {
        padding: var(--space-4);
    }

    h2 {
        font-size: 18px;
    }

    .file-input-group {
        grid-template-columns: 1fr;
    }

    .template-buttons,
    .button-group,
    .download-buttons {
        flex-direction: column;
    }

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

/* ============================================
   INSTRUCTIONS
   ============================================ */

.instructions ol {
    padding-left: var(--space-4);
    line-height: 2;
}

.instructions li {
    margin-bottom: var(--space-2);
    font-size: var(--fs-ui);
    color: var(--fg-2);
}

/* ============================================
   TEMPLATE BUTTONS
   ============================================ */

.template-buttons {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* ============================================
   DATA TABLES
   ============================================ */

.projects-list,
.investors-list {
    margin-top: var(--space-4);
}

.empty-message {
    text-align: center;
    color: var(--fg-2);
    padding: var(--space-6);
    font-style: italic;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg);
    box-shadow: var(--shadow-card);
    border-radius: var(--r-md);
    overflow: hidden;
}

.data-table thead {
    background: var(--viam-carbon);
    color: var(--fg-invert);
}

.data-table th {
    padding: var(--space-3);
    text-align: center;
    font-weight: var(--fw-bold);
    font-size: var(--fs-ui-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    text-align: center;
}

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

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.clickable-row {
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-standard);
}

.clickable-row:hover {
    background: var(--bg-2) !important;
}

/* ============================================
   CALCULATE SECTION
   ============================================ */

.calculate-section {
    text-align: center;
    padding: var(--space-6);
}

.calculate-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.info-card {
    background: var(--bg);
    padding: var(--space-4);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    border-left: 3px solid var(--viam-helios);
    text-align: center;
}

.info-card h3 {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
    font-weight: var(--fw-bold);
}

.info-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: var(--fw-bold);
    color: var(--fg-1);
    margin: 0;
}

/* ============================================
   MATCHING HEADER
   ============================================ */

.matching-header {
    text-align: center;
    padding: var(--space-5);
    background: var(--bg-2);
    border-radius: var(--r-md);
    margin-bottom: var(--space-5);
    border: 1px solid var(--border-subtle);
}

.matching-header #selectedInvestorInfo {
    margin-top: var(--space-3);
    font-size: var(--fs-ui);
    color: var(--fg-1);
}

/* ============================================
   LOADING SPINNER
   ============================================ */

#matchingProgress {
    background: var(--bg);
    padding: var(--space-6);
    border-radius: var(--r-md);
    margin-bottom: var(--space-5);
    text-align: center;
    box-shadow: var(--shadow-card);
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-subtle);
    border-top: 3px solid var(--viam-helios);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    font-size: var(--fs-ui);
    color: var(--fg-1);
    font-weight: var(--fw-medium);
    margin: 0;
}

/* ============================================
   MATCHING RESULTS
   ============================================ */

#matchingResults {
    background: var(--bg);
    padding: var(--space-5);
    border-radius: var(--r-md);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-card);
}

.matching-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

#matchedProjectsList {
    margin-top: var(--space-4);
}

/* ============================================
   MARKETPLACE
   ============================================ */

.marketplace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
    min-height: 500px;
}

.marketplace-column {
    display: flex;
    flex-direction: column;
    background: var(--bg-2);
    border-radius: var(--r-md);
    padding: var(--space-4);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.marketplace-column h2 {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--viam-helios);
    font-size: 18px;
}

.marketplace-column > div {
    flex: 1;
    overflow-y: auto;
}

.investor-item, .project-item {
    background: var(--bg);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-card);
    transition: all var(--dur-fast) var(--ease-standard);
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.investor-item:hover, .project-item:hover {
    transform: translateX(4px);
    border-left-color: var(--viam-helios);
}

.investor-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--viam-helios);
}

.investor-content {
    flex: 1;
}

.project-item {
    cursor: pointer;
}

.investor-item.selected, .project-item.selected {
    border-left-color: var(--status-success);
    background: rgba(34, 197, 94, 0.05);
}

.investor-name {
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
    color: var(--fg-1);
    margin-bottom: var(--space-1);
}

.investor-details {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
}

.investor-detail {
    display: flex;
    flex-direction: column;
}

.investor-detail-label {
    font-size: var(--fs-ui-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    color: var(--fg-2);
    font-weight: var(--fw-bold);
}

.investor-detail-value {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

.project-content {
    flex: 1;
}

.project-id {
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
    color: var(--fg-1);
    margin-bottom: 4px;
}

.project-viam-cost {
    font-size: var(--fs-ui-sm);
    color: var(--fg-2);
    font-weight: var(--fw-medium);
}

.project-price {
    font-size: var(--fs-ui-sm);
    color: var(--fg-2);
    margin-top: 4px;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(4, 13, 13, 0.85);
    animation: fadeIn var(--dur-med) var(--ease-standard);
}

.modal-content {
    background-color: var(--bg);
    margin: 3% auto;
    padding: var(--space-6);
    border-radius: var(--r-lg);
    width: 90%;
    max-width: 800px;
    box-shadow: var(--shadow-float);
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-close {
    color: var(--fg-2);
    position: absolute;
    top: var(--space-4);
    right: var(--space-5);
    font-size: 28px;
    font-weight: var(--fw-bold);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-standard);
}

.modal-close:hover,
.modal-close:focus {
    color: var(--fg-1);
}

#modalProjectTitle,
#modalInvestorTitle {
    font-family: var(--font-display);
    color: var(--fg-1);
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-3);
}

.modal-actions {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: center;
    gap: var(--space-3);
}

.modal-actions .btn {
    min-width: 140px;
}

.modal-actions .btn-danger {
    background: transparent;
    border: 1px solid var(--status-danger);
    color: var(--status-danger);
}

.modal-actions .btn-danger:hover {
    background: var(--status-danger);
    color: white;
}

/* ============================================
   EDIT GRID
   ============================================ */

.edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.edit-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.edit-item label {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--fw-bold);
}

.edit-item input {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    font-size: var(--fs-ui);
    font-family: var(--font-body);
    transition: border-color var(--dur-fast) var(--ease-standard);
}

.edit-item input:focus {
    outline: none;
    border-color: var(--viam-helios);
}

.edit-item input:read-only {
    background: var(--bg-2);
    color: var(--fg-2);
    cursor: not-allowed;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

.detail-item {
    background: var(--bg-2);
    padding: var(--space-4);
    border-radius: var(--r-sm);
    border-left: 3px solid var(--viam-helios);
}

.detail-label {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
    font-weight: var(--fw-bold);
}

.detail-value {
    font-size: 18px;
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.progress-section,
.results-section,
.error-section {
    animation: fadeIn var(--dur-slow) var(--ease-standard);
}

/* ============================================
   MULTI-INVESTOR RESULTS
   ============================================ */

.investor-results-section {
    background: var(--bg-2);
    border-radius: var(--r-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border-left: 3px solid var(--viam-helios);
    border: 1px solid var(--border-subtle);
}

.investor-results-section h4 {
    color: var(--fg-1);
    margin: 0 0 var(--space-3) 0;
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
}

.investor-summary {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.investor-summary span {
    font-size: var(--fs-ui-sm);
    color: var(--fg-2);
}

.investor-results-section .data-table {
    margin-top: var(--space-2);
}

/* ============================================
   QUICK STATS BAR
   ============================================ */

.quick-stats {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--viam-teal);
    border-bottom: 1px solid var(--viam-carbon);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--fg-invert);
    font-size: var(--fs-ui-sm);
}

.stat-item strong {
    color: var(--viam-helios);
}

/* ============================================
   TOOLTIP
   ============================================ */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--viam-carbon);
    color: var(--fg-invert);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--r-sm);
    font-size: var(--fs-ui-xs);
    white-space: nowrap;
    z-index: 100;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: var(--space-2);
}

.status-dot.active {
    background: var(--status-success);
}

.status-dot.inactive {
    background: var(--fg-2);
}

/* ============================================
   PERFECT MATCH SECTION
   ============================================ */

.perfect-match-section {
    background: var(--bg-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    text-align: center;
}

.perfect-match-section.perfected {
    background: rgba(34, 197, 94, 0.05);
    border-color: var(--status-success);
}

.gap-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    background: var(--bg);
    border-radius: var(--r-sm);
}

.gap-label {
    font-size: var(--fs-ui);
    color: var(--fg-2);
    font-weight: var(--fw-medium);
}

.gap-value {
    font-size: 24px;
    font-weight: var(--fw-bold);
    color: var(--fg-1);
}

.gap-highlight {
    color: var(--status-warning);
    font-weight: var(--fw-medium);
}

.perfect-match-hint {
    margin-top: var(--space-3);
    font-size: var(--fs-ui-sm);
    color: var(--fg-2);
    font-style: italic;
}

.perfected-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--status-success);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--r-sm);
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--viam-carbon);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: var(--space-4);
}

.login-card {
    background: var(--bg);
    border-radius: var(--r-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-float);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-5);
}

.login-logo {
    height: 48px;
    margin-bottom: var(--space-4);
}

.login-header h1 {
    font-family: var(--font-display);
    color: var(--fg-1);
    font-size: 24px;
    font-weight: var(--fw-medium);
    margin-bottom: var(--space-2);
}

.login-subtitle {
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-group label {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
    font-size: var(--fs-ui-sm);
}

.form-group input,
.form-group select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    font-size: var(--fs-ui);
    font-family: var(--font-body);
    transition: border-color var(--dur-fast) var(--ease-standard);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--viam-helios);
}

.form-group input::placeholder {
    color: var(--fg-2);
}

.login-btn {
    margin-top: var(--space-2);
    width: 100%;
    justify-content: center;
}

.login-footer {
    margin-top: var(--space-5);
    text-align: center;
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
}

.login-footer a {
    color: var(--fg-1);
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.flash-message {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--r-sm);
    margin-bottom: var(--space-4);
    font-size: var(--fs-ui-sm);
}

.flash-error {
    background: rgba(239, 68, 68, 0.05);
    color: var(--status-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.flash-info {
    background: var(--bg-2);
    color: var(--fg-1);
    border: 1px solid var(--border-subtle);
}

.flash-success {
    background: rgba(34, 197, 94, 0.05);
    color: var(--status-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ============================================
   HEADER ACTIONS
   ============================================ */

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: var(--space-2);
}

.user-name {
    font-weight: var(--fw-medium);
    color: var(--fg-invert);
    font-size: var(--fs-ui-sm);
}

.user-role {
    font-size: var(--fs-ui-xs);
    color: var(--viam-helios);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-btn {
    border-color: var(--viam-steel);
    color: var(--fg-invert);
    background: transparent;
}

.logout-btn:hover {
    background: var(--viam-teal);
    border-color: var(--viam-steel);
}

/* ============================================
   INVESTOR PORTAL
   ============================================ */

.investor-profile-section {
    margin-bottom: var(--space-5);
}

.investor-profile-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-3);
}

.profile-card {
    background: var(--bg);
    border-radius: var(--r-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-card);
    border-left: 3px solid var(--viam-helios);
}

.profile-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
    margin-bottom: var(--space-2);
}

.profile-card-header svg {
    color: var(--fg-1);
}

.profile-card-value {
    font-size: 20px;
    font-weight: var(--fw-bold);
    color: var(--fg-1);
}

/* ============================================
   BUDGET TRACKER
   ============================================ */

.budget-tracker-section {
    margin-bottom: var(--space-5);
}

.budget-tracker {
    background: var(--bg);
    border-radius: var(--r-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-card);
}

.budget-bar {
    height: 12px;
    background: var(--border-subtle);
    border-radius: var(--r-sm);
    overflow: hidden;
    margin-bottom: var(--space-4);
}

.budget-bar-fill {
    height: 100%;
    background: var(--viam-helios);
    border-radius: var(--r-sm);
    transition: width var(--dur-slow) var(--ease-standard);
}

.budget-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.budget-stat {
    text-align: center;
}

.budget-stat-label {
    display: block;
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-1);
    font-weight: var(--fw-bold);
}

.budget-stat-value {
    font-size: 20px;
    font-weight: var(--fw-bold);
    color: var(--fg-1);
}

/* ============================================
   INVESTOR ACTIONS
   ============================================ */

.investor-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    background: var(--bg-2);
    border-radius: var(--r-md);
}

/* ============================================
   PROJECT SELECTION GRID
   ============================================ */

.project-selection-section {
    margin-bottom: var(--space-5);
}

.project-grid-scroll-container {
    max-height: 520px;
    overflow-y: auto;
    padding-right: var(--space-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    background: var(--bg-2);
    padding: var(--space-3);
}

.project-grid-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.project-grid-scroll-container::-webkit-scrollbar-track {
    background: var(--border-subtle);
    border-radius: var(--r-sm);
}

.project-grid-scroll-container::-webkit-scrollbar-thumb {
    background: var(--viam-steel);
    border-radius: var(--r-sm);
}

.project-grid-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--fg-2);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-3);
}

.project-select-card {
    background: var(--bg);
    border-radius: var(--r-md);
    padding: var(--space-3);
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    transition: all var(--dur-fast) var(--ease-standard);
}

.project-select-card:hover {
    border-color: var(--viam-helios);
    transform: translateY(-2px);
}

.project-select-card.selected {
    border-color: var(--status-success);
    background: rgba(34, 197, 94, 0.05);
}

.project-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.project-select-id {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

.project-select-checkbox {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.project-select-checkbox.checked {
    background: var(--status-success);
    border-color: var(--status-success);
    color: white;
}

.project-select-details {
    display: flex;
    justify-content: space-between;
}

.project-select-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.project-select-detail .label {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
}

.project-select-detail .value {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

/* ============================================
   MY PURCHASES SECTION
   ============================================ */

.my-purchases-section {
    margin-bottom: var(--space-5);
}

/* ============================================
   STATUS BADGES
   ============================================ */

.status-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-ui-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-selected {
    background: rgba(234, 179, 8, 0.1);
    color: var(--status-warning);
}

.status-confirmed {
    background: var(--bg-3);
    color: var(--fg-2);
}

.status-approved {
    background: rgba(34, 197, 94, 0.1);
    color: var(--status-success);
}

/* ============================================
   LOADING MODAL
   ============================================ */

.loading-modal {
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-modal .modal-content {
    background: var(--bg);
    padding: var(--space-6);
    text-align: center;
}

/* ============================================
   ADMIN PANEL
   ============================================ */

.create-user-section {
    background: var(--bg-2);
    border-radius: var(--r-md);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
}

.create-user-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
}

.users-list-section,
.purchases-list-section {
    margin-bottom: var(--space-5);
}

/* ============================================
   ROLE BADGES
   ============================================ */

.role-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-ui-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
}

.role-admin {
    background: var(--viam-carbon);
    color: var(--fg-invert);
}

.role-investor {
    background: var(--viam-helios);
    color: var(--viam-carbon);
}

/* ============================================
   STATUS INDICATORS
   ============================================ */

.status-active {
    color: var(--status-success);
    font-weight: var(--fw-medium);
}

.status-inactive {
    color: var(--fg-2);
}

/* ============================================
   ACTION CELLS
   ============================================ */

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn {
    margin: 2px;
}

/* ============================================
   TEXT UTILITIES
   ============================================ */

.text-muted {
    color: var(--fg-2);
}

.text-success {
    color: var(--status-success);
}

/* ============================================
   SELECTED PROJECTS SUMMARY
   ============================================ */

.selected-projects-section {
    background: rgba(34, 197, 94, 0.05);
    border: 1px solid var(--status-success);
    border-radius: var(--r-md);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
}

.selected-projects-section h2 {
    color: var(--status-success);
    border-bottom-color: var(--status-success);
    margin-bottom: var(--space-3);
}

.selected-projects-section h2 span {
    font-weight: var(--fw-regular);
    color: var(--fg-2);
}

.selected-projects-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: var(--space-4);
}

.selected-projects-list-column {
    display: flex;
    flex-direction: column;
}

.selected-projects-summary {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    flex: 1;
}

.selected-project-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-card);
    border-left: 3px solid var(--status-success);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-standard);
}

.selected-project-row:hover {
    background: rgba(34, 197, 94, 0.05);
}

.selected-project-row.viewing {
    border-left-color: var(--viam-helios);
    background: var(--bg-2);
}

.selected-project-info {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.selected-project-id {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
    min-width: 100px;
}

.selected-project-downpayment {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
    font-size: var(--fs-ui);
    min-width: 120px;
    text-align: left;
}

.btn-remove {
    background: transparent;
    border: 1px solid var(--status-danger);
    color: var(--status-danger);
    padding: var(--space-1) var(--space-2);
    font-size: var(--fs-ui-xs);
}

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

.selected-projects-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--status-success);
    border-radius: var(--r-sm);
    color: white;
    font-size: var(--fs-ui);
}

.selected-projects-total strong {
    font-size: 20px;
}

/* ============================================
   SELECTED STREET VIEW COLUMN
   ============================================ */

.selected-street-view-column {
    display: flex;
    flex-direction: column;
}

.street-view-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--viam-carbon);
    border-radius: var(--r-sm);
}

.street-view-nav-label {
    color: var(--fg-invert);
    font-weight: var(--fw-medium);
    font-size: var(--fs-ui-sm);
}

.btn-nav {
    background: transparent;
    border: 1px solid var(--viam-steel);
    color: var(--fg-invert);
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-nav:hover {
    background: var(--viam-teal);
    border-color: var(--viam-steel);
}

@media (max-width: 900px) {
    .selected-projects-layout {
        grid-template-columns: 1fr;
    }

    .selected-street-view-column {
        order: -1;
    }
}

/* ============================================
   STREET VIEW LAYOUT
   ============================================ */

.project-selection-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: var(--space-5);
}

.project-list-column h2,
.street-view-column h2 {
    margin-bottom: var(--space-3);
}

.street-view-column {
    position: sticky;
    top: var(--space-4);
    height: fit-content;
}

.street-view-container {
    background: var(--bg-2);
    border-radius: var(--r-md);
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
}

.street-view-image {
    width: 100%;
    height: auto;
    display: block;
}

.street-view-address {
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--viam-carbon);
    color: var(--fg-invert);
    border-radius: var(--r-sm);
    font-size: var(--fs-ui-sm);
    text-align: center;
}

.street-view-address:empty {
    display: none;
}

@media (max-width: 900px) {
    .project-selection-layout {
        grid-template-columns: 1fr;
    }

    .street-view-column {
        position: static;
        order: -1;
    }
}

/* ============================================
   MATCHED PROJECTS TAB
   ============================================ */

.matched-summary {
    margin-bottom: var(--space-4);
}

.matched-description {
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
    margin-top: var(--space-2);
}

.matched-investors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-4);
}

.matched-investor-card {
    background: var(--bg);
    border-radius: var(--r-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-card);
    border-left: 3px solid var(--status-success);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-standard);
}

.matched-investor-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-float);
    border-left-color: var(--viam-helios);
}

.matched-investor-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.matched-investor-header h3 {
    margin: 0;
    font-size: var(--fs-ui);
    color: var(--fg-1);
    flex: 1;
}

.matched-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--viam-helios);
    flex-shrink: 0;
}

.matched-badge {
    background: var(--status-success);
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-ui-xs);
    font-weight: var(--fw-bold);
}

.matched-investor-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.matched-stat {
    text-align: center;
}

.matched-stat-label {
    display: block;
    font-size: 10px;
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    font-weight: var(--fw-bold);
}

.matched-stat-value {
    font-size: var(--fs-ui-sm);
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

.matched-investor-footer {
    text-align: center;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-subtle);
}

.view-details-hint {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
}

/* ============================================
   MATCHED INVESTOR MODAL
   ============================================ */

.matched-modal-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-2);
    border-radius: var(--r-sm);
}

.matched-modal-summary .summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.matched-modal-summary .label {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.matched-modal-summary .value {
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

#modalMatchedProjects {
    margin-top: var(--space-3);
    max-height: 300px;
    overflow-y: auto;
}

#modalMatchedProjects .data-table {
    font-size: var(--fs-ui-sm);
}

#modalMatchedInvestorTitle {
    color: var(--fg-1);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

/* ============================================
   INVESTOR RESULTS HEADER
   ============================================ */

.investor-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.investor-results-header h4 {
    margin: 0;
}

.remove-investor-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--status-danger);
    border-color: var(--status-danger);
    font-size: var(--fs-ui-xs);
    padding: var(--space-1) var(--space-2);
}

.remove-investor-btn:hover {
    background: var(--status-danger);
    color: white;
}

/* ============================================
   SKIPPED INVESTORS
   ============================================ */

.skipped-investors-section {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px dashed var(--border-subtle);
}

.skipped-investors-section h4 {
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
    margin-bottom: var(--space-1);
}

.skipped-hint {
    color: var(--fg-2);
    font-size: var(--fs-ui-xs);
    margin-bottom: var(--space-3);
}

.skipped-investors-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.skipped-investor-chip {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-pill);
    padding: var(--space-1) var(--space-2);
    font-size: var(--fs-ui-sm);
}

.skipped-investor-chip .restore-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fg-1);
    font-size: var(--fs-ui);
    padding: 0;
    line-height: 1;
}

.skipped-investor-chip .restore-btn:hover {
    color: var(--status-success);
}

/* ============================================
   MARKUP PREVIEW PANEL
   ============================================ */

.projects-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.projects-header-actions .left-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ============================================
   PREVIEW NUMBERS CTA
   ============================================ */

.preview-numbers-cta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--viam-carbon);
    border: 1px solid var(--viam-steel);
    border-radius: var(--r-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-standard);
    min-width: 280px;
}

.preview-numbers-cta:hover {
    border-color: var(--viam-helios);
    transform: translateY(-2px);
}

.preview-numbers-cta.preview-active {
    border-color: var(--status-success);
    background: var(--viam-teal);
}

.preview-cta-icon {
    width: 36px;
    height: 36px;
    background: var(--viam-teal);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-invert);
    flex-shrink: 0;
}

.preview-numbers-cta:hover .preview-cta-icon {
    background: var(--viam-helios);
    color: var(--viam-carbon);
}

.preview-numbers-cta.preview-active .preview-cta-icon {
    background: var(--status-success);
}

.preview-cta-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
}

.preview-cta-title {
    color: var(--fg-invert);
    font-size: var(--fs-ui-sm);
    font-weight: var(--fw-medium);
}

.preview-cta-subtitle {
    color: var(--viam-steel);
    font-size: var(--fs-ui-xs);
}

.preview-numbers-cta.preview-active .preview-cta-subtitle {
    color: var(--status-success);
}

.preview-cta-arrow {
    color: var(--viam-steel);
    flex-shrink: 0;
    transition: transform var(--dur-fast) var(--ease-standard);
}

.preview-numbers-cta:hover .preview-cta-arrow {
    color: var(--viam-helios);
    transform: translateX(3px);
}

/* ============================================
   MARKUP TIER
   ============================================ */

.markup-tier {
    background: var(--viam-teal);
    border-radius: var(--r-sm);
    padding: var(--space-2);
    flex: 1;
    min-width: 100px;
    transition: all var(--dur-fast) var(--ease-standard);
    border: 1px solid transparent;
}

.markup-tier:hover {
    background: rgba(21, 44, 46, 0.8);
}

.markup-tier.active {
    border-color: var(--viam-helios);
    background: rgba(234, 255, 153, 0.1);
}

.tier-input input:focus {
    outline: none;
    border-color: var(--viam-helios);
}

.markup-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.preview-markup-btn {
    flex: 1;
    justify-content: center;
}

.clear-markup-btn {
    border-color: var(--status-danger);
    color: var(--status-danger);
    background: transparent;
}

.clear-markup-btn:hover {
    background: var(--status-danger);
    border-color: var(--status-danger);
    color: white;
}

/* ============================================
   ACTIVE TIER BADGE
   ============================================ */

.active-tier-badge {
    background: var(--viam-helios);
    color: var(--viam-carbon);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-ui-xs);
    font-weight: var(--fw-bold);
    margin-left: var(--space-2);
    vertical-align: middle;
}

/* ============================================
   MARKUP LOADING
   ============================================ */

.markup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--bg-2);
    border-radius: var(--r-sm);
    margin-bottom: var(--space-4);
}

.markup-loading .spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.markup-loading span {
    color: var(--fg-1);
    font-weight: var(--fw-medium);
}

/* ============================================
   DATA TABLE COLUMN STYLES
   ============================================ */

.data-table .viam-markup-col {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

.data-table .viam-markup-col.positive {
    color: var(--status-success);
}

.data-table .viam-markup-col.negative {
    color: var(--status-danger);
}

.data-table .vpp-revenue-col {
    color: var(--fg-1);
    font-weight: var(--fw-medium);
}

.data-table .downpayment-col {
    font-weight: var(--fw-medium);
    color: var(--fg-1);
}

/* ============================================
   TIER SUMMARY SECTION
   ============================================ */

.tier-summary-section {
    background: var(--bg-2);
    border-radius: var(--r-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border-subtle);
}

.tier-summary-section h3 {
    color: var(--fg-1);
    font-size: var(--fs-ui);
    margin: 0 0 var(--space-3) 0;
    font-weight: var(--fw-medium);
}

.tier-summary-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-3);
}

.tier-summary-card {
    background: var(--bg);
    border-radius: var(--r-sm);
    padding: var(--space-3);
    text-align: center;
    box-shadow: var(--shadow-card);
    border-top: 3px solid var(--viam-helios);
}

.tier-summary-card.total {
    border-top-color: var(--viam-helios);
}

.tier-summary-label {
    font-size: var(--fs-ui-sm);
    color: var(--fg-2);
    font-weight: var(--fw-medium);
    margin-bottom: 4px;
}

.tier-summary-count {
    font-size: var(--fs-ui-xs);
    color: var(--fg-2);
    margin-bottom: var(--space-2);
}

.tier-summary-value {
    font-size: 24px;
    font-weight: var(--fw-bold);
    color: var(--fg-1);
}

.tier-summary-card.total .tier-summary-value {
    color: var(--fg-1);
}

.tier-summary-card.viam-margin {
    border-top-color: var(--viam-helios);
}

.tier-summary-card.viam-margin .tier-summary-value {
    font-size: 20px;
}

.tier-summary-card.viam-margin .tier-summary-value.positive {
    color: var(--status-success);
}

.tier-summary-card.viam-margin .tier-summary-value.negative {
    color: var(--status-danger);
}

.tier-summary-card.viam-margin .tier-summary-label {
    font-weight: var(--fw-medium);
}

@media (max-width: 900px) {
    .projects-header-actions {
        flex-direction: column;
    }

    .preview-numbers-cta {
        width: 100%;
        min-width: unset;
    }

    .tier-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   PREVIEW SETTINGS DRAWER
   ============================================ */

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(4, 13, 13, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-med) var(--ease-standard), visibility var(--dur-med) var(--ease-standard);
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.settings-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border-subtle);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right var(--dur-med) var(--ease-standard);
    box-shadow: var(--shadow-float);
}

.settings-drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--viam-carbon);
    color: var(--fg-invert);
}

.drawer-header h3 {
    margin: 0;
    font-size: var(--fs-ui);
    font-weight: var(--fw-medium);
}

.drawer-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--viam-steel);
    line-height: 1;
    padding: 0;
    transition: color var(--dur-fast) var(--ease-standard);
}

.drawer-close-btn:hover {
    color: var(--fg-invert);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.drawer-section {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.drawer-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.drawer-section h4 {
    margin: 0 0 var(--space-3) 0;
    color: var(--fg-1);
    font-size: var(--fs-ui-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--fw-bold);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    color: var(--fg-2);
    font-size: var(--fs-ui-sm);
}

.setting-row input {
    width: 100px;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    background: var(--bg-2);
    color: var(--fg-1);
    text-align: right;
    font-size: var(--fs-ui-sm);
    font-family: var(--font-body);
    transition: border-color var(--dur-fast) var(--ease-standard);
}

.setting-row input:focus {
    outline: none;
    border-color: var(--viam-helios);
    background: var(--bg);
}

.drawer-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: var(--space-2);
    background: var(--bg-2);
}

.drawer-footer .btn {
    flex: 1;
    justify-content: center;
}

.markup-preview-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-btn {
    background: var(--viam-teal);
    border: 1px solid var(--viam-steel);
    border-radius: var(--r-sm);
    padding: var(--space-1);
    cursor: pointer;
    color: var(--fg-invert);
    transition: all var(--dur-fast) var(--ease-standard);
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--viam-helios);
    color: var(--viam-carbon);
    border-color: var(--viam-helios);
}

@media (max-width: 500px) {
    .settings-drawer {
        width: 100%;
        max-width: 100%;
        right: -100%;
    }
}
