/* CI Ventures Brand Colors */
:root {
    --ci-navy: #162c3a;
    --ci-golden: #fdb245;
    --ci-coral: #fd553c;
    --ci-white: #ffffff;
    --ci-teal: #2e9bb8;
    --ci-light-teal: #5acbc5;
    --ci-blue: #2f6594;
    --ci-light-bg: #f7f9fa;
    --ci-border: #e1e8ed;

    /* Semantic colors */
    --ci-hint-text: #5a6d7c;  /* WCAG AA compliant for contrast */
    --ci-warning-text: #8a5a00;
    --ci-error-text: #b84432;

    /* Border radius scale */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--ci-navy);
    background: var(--ci-light-bg);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    margin-bottom: 2rem;
    padding: 1.75rem 2rem;
    background: var(--ci-navy);
    border-radius: 12px;
    color: var(--ci-white);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

header .logo {
    width: 130px;
    height: 130px;
    background: url('/static/logo-white.png') no-repeat center;
    background-size: contain;
    flex-shrink: 0;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

header h1 {
    font-size: 2rem;
    color: var(--ci-white);
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
}

.tagline {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.1rem;
    margin: 0;
}

.byline {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    margin: 0.25rem 0 0 0;
    font-style: italic;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.alert-warning {
    background: #fef3e2;
    border: 1px solid var(--ci-golden);
    color: var(--ci-warning-text);
}

/* Main content */
main {
    flex: 1;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--ci-border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: var(--ci-white);
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.highlight {
    border-color: var(--ci-teal);
    background: #f0f9fb;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-area p {
    margin: 0.5rem 0;
    color: var(--ci-blue);
}

.or {
    font-size: 0.9rem;
    color: var(--ci-hint-text);
}

.file-input-label {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--ci-golden);
    color: var(--ci-navy);
    border-radius: 6px;
    cursor: pointer;
    margin: 1rem 0;
    transition: all 0.2s ease;
    font-weight: 600;
}

.file-input-label:hover {
    background: #e9a03d;
    transform: translateY(-1px);
}

.file-input-label input {
    display: none;
}

.hint {
    font-size: 0.85rem;
    color: var(--ci-hint-text);
}

/* File list */
.file-list {
    margin: 1rem 0;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--ci-white);
    border: 1px solid var(--ci-border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.file-name {
    flex: 1;
    font-weight: 500;
    color: var(--ci-navy);
}

.file-size {
    color: var(--ci-blue);
    font-size: 0.9rem;
    margin-right: 1rem;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--ci-hint-text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.remove-btn:hover {
    color: var(--ci-coral);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

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

.btn-primary {
    background: var(--ci-golden);
    color: var(--ci-navy);
    width: 100%;
    margin-top: 1rem;
}

.btn-primary:hover:not(:disabled) {
    background: #e9a03d;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--ci-teal);
    color: var(--ci-white);
}

.btn-secondary:hover {
    background: #268a9e;
}

/* Progress Section */
.progress-section {
    background: var(--ci-white);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--ci-border);
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.progress-info {
    flex: 1;
}

.progress-status {
    font-weight: 600;
    color: var(--ci-navy);
    margin: 0;
}

.progress-file {
    color: var(--ci-blue);
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
    font-family: monospace;
}

.progress-bar-wrapper {
    height: 8px;
    background: var(--ci-border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ci-teal), var(--ci-light-teal));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-count {
    text-align: center;
    font-size: 0.85rem;
    color: var(--ci-blue);
    margin: 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--ci-border);
    border-top-color: var(--ci-golden);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

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

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
        border-top-color: var(--ci-golden);
        opacity: 0.7;
    }

    .document-card {
        animation: none;
    }
}

/* Fade-in animation for document cards */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.document-card.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Results */
.results {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-header h2 {
    font-size: 1.5rem;
    color: var(--ci-navy);
}

/* Summary section */
.summary-section {
    background: var(--ci-white);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--ci-border);
}

.summary-section h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--ci-navy);
}

.score-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.score {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--ci-navy);
}

.readiness {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

.readiness.ready {
    background: #e6f7f5;
    color: #1a7a6d;
}

.readiness.ready-with-caveats {
    background: #fef3e2;
    color: var(--ci-warning-text);
}

.readiness.needs-work {
    background: #fef0ed;
    color: var(--ci-error-text);
}

.readiness.not-ready {
    background: #fde8e5;
    color: #c4392a;
}

.assessment {
    color: var(--ci-blue);
    line-height: 1.7;
}

.gaps, .contradictions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ci-border);
}

.gaps h4, .contradictions h4 {
    margin-bottom: 0.75rem;
    color: var(--ci-blue);
    font-size: 1rem;
}

.gaps ul, .contradictions ul {
    padding-left: 1.25rem;
}

.gaps li, .contradictions li {
    margin-bottom: 0.5rem;
}

/* Document cards */
#documents-section h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--ci-navy);
}

.document-card {
    background: var(--ci-white);
    border: 1px solid var(--ci-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.document-header h4 {
    font-size: 1.1rem;
    color: var(--ci-navy);
}

.doc-type {
    background: #e6f0f5;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--ci-blue);
    font-weight: 500;
}

.document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--ci-blue);
}

/* Overall Score Bar */
.overall-score {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--ci-light-bg);
    border-radius: 8px;
}

.score-label {
    font-weight: 600;
    color: var(--ci-navy);
    min-width: 100px;
}

.score-bar-container {
    flex: 1;
    height: 12px;
    background: var(--ci-border);
    border-radius: 6px;
    overflow: hidden;
}

.score-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ci-light-teal) 0%, var(--ci-teal) 50%, var(--ci-golden) 75%, var(--ci-coral) 100%);
    background-size: 1000% 100%;
    background-position: right;
    border-radius: 6px;
    transition: width 0.3s ease;
}

.score-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ci-navy);
    min-width: 45px;
    text-align: right;
}

/* Dimension Scores */
.dimension-scores {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--ci-light-bg);
    border-radius: 8px;
    border: 1px solid var(--ci-border);
}

.dimension-score {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dim-name {
    min-width: 140px;
    font-size: 0.85rem;
    color: var(--ci-blue);
}

.dim-bar-container {
    flex: 1;
    height: 8px;
    background: var(--ci-border);
    border-radius: 4px;
    overflow: hidden;
}

.dim-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.dim-bar.score-low {
    background: var(--ci-coral);
}

.dim-bar.score-medium {
    background: var(--ci-golden);
}

.dim-bar.score-good {
    background: var(--ci-teal);
}

.dim-bar.score-high {
    background: var(--ci-light-teal);
}

.dim-value {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ci-navy);
    min-width: 20px;
    text-align: right;
}

/* Metrics Grid (Financials) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.metric {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: var(--ci-light-bg);
    border-radius: 6px;
    border: 1px solid var(--ci-border);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--ci-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-weight: 600;
    color: var(--ci-navy);
    font-size: 0.95rem;
}

.unit-econ {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--ci-blue);
}

/* Ownership Grid (Cap Table) */
.ownership-grid {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ownership-item {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: var(--ci-light-bg);
    border-radius: 8px;
    border: 1px solid var(--ci-border);
}

.own-label {
    display: block;
    font-size: 0.75rem;
    color: var(--ci-blue);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.own-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ci-navy);
}

/* Terms Grid (Term Sheet) */
.terms-grid {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.term-item {
    display: flex;
    gap: 0.5rem;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--ci-border);
}

.term-item span:first-child {
    font-weight: 500;
    color: var(--ci-blue);
    min-width: 120px;
}

/* Red Flags */
.red-flags-section {
    background: #fef0ed;
    border: 1px solid #fdd5ce;
    border-radius: 8px;
    padding: 1rem;
}

.red-flags-section h5 {
    color: var(--ci-coral);
}

.red-flags-list {
    color: var(--ci-error-text);
}

.red-flags-list li {
    margin-bottom: 0.5rem;
}

/* Risks Section */
.risks-section {
    background: #fef8ed;
    border: 1px solid #fde5c2;
    border-radius: 8px;
    padding: 1rem;
}

.risks-section h5 {
    color: #c07b00;
}

/* Missing Elements */
.missing-section {
    background: #e6f4f8;
    border: 1px solid #b8dce8;
    border-radius: 8px;
    padding: 1rem;
}

.missing-section h5 {
    color: var(--ci-teal);
}

/* Negotiation Section */
.negotiation-section {
    background: #e6f7f5;
    border: 1px solid #b8e8e3;
    border-radius: 8px;
    padding: 1rem;
}

.negotiation-section h5 {
    color: #1a7a6d;
}

.document-card .summary {
    color: var(--ci-blue);
    margin-bottom: 1rem;
}

details {
    border-top: 1px solid var(--ci-border);
    padding-top: 1rem;
}

details summary {
    cursor: pointer;
    color: var(--ci-teal);
    font-weight: 500;
}

details summary:hover {
    color: var(--ci-navy);
    text-decoration: underline;
}

.details-content {
    margin-top: 1rem;
}

.details-content .section {
    margin-bottom: 1rem;
}

.details-content h5 {
    font-size: 0.95rem;
    color: var(--ci-navy);
    margin-bottom: 0.5rem;
}

.details-content ul, .details-content ol {
    padding-left: 1.25rem;
}

.details-content li {
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

/* Errors */
.errors-section {
    background: var(--ci-white);
    border: 1px solid #fdd5ce;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.errors-section h3 {
    color: var(--ci-coral);
    margin-bottom: 1rem;
}

.error-item {
    padding: 0.75rem;
    background: #fef0ed;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--ci-error-text);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ci-border);
    color: var(--ci-blue);
    font-size: 0.9rem;
}

footer strong {
    color: var(--ci-navy);
}

/* Completeness Section */
.completeness-section {
    background: var(--ci-white);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--ci-border);
}

.completeness-section h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--ci-navy);
}

.completeness-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--ci-border);
}

.completeness-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 6px solid;
    box-sizing: content-box;
    flex-shrink: 0;
}

.completeness-score.complete-high {
    border-color: var(--ci-light-teal);
    background: #e6f7f5;
}

.completeness-score.complete-medium {
    border-color: var(--ci-golden);
    background: #fef8ed;
}

.completeness-score.complete-low {
    border-color: var(--ci-coral);
    background: #fef0ed;
}

.completeness-score .score-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ci-navy);
    line-height: 1;
    margin: 0;
    padding: 0;
}

.completeness-score .score-label {
    font-size: 0.7rem;
    color: var(--ci-blue);
    text-transform: uppercase;
    line-height: 1;
    margin-top: 4px;
    letter-spacing: 0.5px;
    font-weight: 600;
    min-width: auto;
}

.completeness-stage {
    display: flex;
    flex-direction: column;
}

.completeness-stage .stage-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ci-navy);
}

.completeness-stage .found-count {
    font-size: 0.9rem;
    color: var(--ci-blue);
    margin-top: 0.25rem;
}

.found-docs {
    margin-bottom: 1.5rem;
}

.found-docs h4, .next-priority h4 {
    font-size: 0.9rem;
    color: var(--ci-blue);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.doc-tag {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.doc-tag.found {
    background: #e6f7f5;
    color: #1a7a6d;
}

.doc-tag.missing {
    background: var(--ci-light-bg);
    color: var(--ci-blue);
    border: 1px dashed var(--ci-border);
}

.doc-tag.missing.required {
    background: #fef0ed;
    color: var(--ci-error-text);
    border-color: #fdd5ce;
}

.doc-tag.missing.recommended {
    background: #fef8ed;
    color: var(--ci-warning-text);
    border-color: #fde5c2;
}

.doc-tag.missing.nice {
    background: var(--ci-light-bg);
    color: var(--ci-blue);
    border-color: var(--ci-border);
}

.next-priority {
    margin-bottom: 1.5rem;
}

.priority-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.priority-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--ci-light-bg);
    border-radius: 8px;
    border-left: 4px solid;
}

.priority-item.required {
    border-left-color: var(--ci-coral);
    background: #fef0ed;
}

.priority-item.recommended {
    border-left-color: var(--ci-golden);
    background: #fef8ed;
}

.priority-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--ci-white);
    border-radius: 50%;
    font-weight: 700;
    color: var(--ci-navy);
    flex-shrink: 0;
}

.priority-content {
    flex: 1;
}

.priority-content strong {
    font-size: 1rem;
    color: var(--ci-navy);
}

.priority-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-badge.required {
    background: var(--ci-coral);
    color: var(--ci-white);
}

.priority-badge.recommended {
    background: var(--ci-golden);
    color: var(--ci-navy);
}

.priority-why {
    margin: 0.5rem 0 0.25rem;
    font-size: 0.9rem;
    color: var(--ci-blue);
}

.priority-examples {
    font-size: 0.8rem;
    color: var(--ci-hint-text);
    font-style: italic;
}

.missing-details {
    border-top: 1px solid var(--ci-border);
    padding-top: 1rem;
}

.missing-details summary {
    cursor: pointer;
    color: var(--ci-blue);
    font-size: 0.9rem;
}

.missing-details summary:hover {
    color: var(--ci-navy);
}

.missing-content {
    margin-top: 1rem;
}

.missing-group {
    margin-bottom: 1rem;
}

.missing-group h5 {
    font-size: 0.8rem;
    color: var(--ci-blue);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    header {
        padding: 1.25rem;
        border-radius: 8px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    header .logo {
        width: 100px;
        height: 100px;
    }

    header h1 {
        font-size: 1.5rem;
        white-space: nowrap;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .byline {
        font-size: 0.75rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .document-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .overall-score {
        flex-wrap: wrap;
    }

    .score-label {
        width: 100%;
        min-width: auto;
    }

    .dim-name {
        min-width: 100px;
        font-size: 0.8rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .ownership-grid {
        flex-direction: column;
    }

    .ownership-item {
        padding: 0.75rem;
    }

    .own-value {
        font-size: 1.25rem;
    }

    .completeness-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .completeness-score {
        width: 80px;
        height: 80px;
    }

    .completeness-score .score-number {
        font-size: 1.4rem;
    }

    .completeness-score .score-label {
        font-size: 0.6rem;
    }

    .priority-item {
        flex-direction: column;
        gap: 0.5rem;
    }

    .priority-num {
        align-self: flex-start;
    }
}

/* History Button */
.btn-history {
    background: transparent;
    border: 2px solid var(--ci-golden);
    color: var(--ci-golden);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    margin-left: auto;
}

.btn-history:hover {
    background: var(--ci-golden);
    color: var(--ci-navy);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(22, 44, 58, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--ci-white);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--ci-navy);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--ci-blue);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--ci-coral);
}

.modal-body {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-loading,
.history-empty,
.history-error {
    text-align: center;
    padding: 2rem;
    color: var(--ci-blue);
}

.history-error {
    color: var(--ci-coral);
}

.history-item {
    padding: 0.75rem 1rem;
    background: var(--ci-light-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.history-item:hover {
    background: #e6f0f5;
    border-left-color: var(--ci-teal);
}

.history-item.score-low {
    border-left-color: var(--ci-coral);
}

.history-item.score-medium {
    border-left-color: var(--ci-golden);
}

.history-item.score-good {
    border-left-color: var(--ci-teal);
}

.history-item.score-high {
    border-left-color: var(--ci-light-teal);
}

.history-text {
    font-size: 0.9rem;
    color: var(--ci-navy);
    line-height: 1.4;
}

/* Mobile responsive for history */
@media (max-width: 600px) {
    .btn-history {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .modal-content {
        max-height: 90vh;
    }

    .history-text {
        font-size: 0.8rem;
    }
}

/* ============== Authentication Styles ============== */

/* Header actions */
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-login {
    background: transparent;
    border: 2px solid var(--ci-golden);
    color: var(--ci-golden);
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

.btn-login:hover {
    background: var(--ci-golden);
    color: var(--ci-navy);
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.85);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    color: var(--ci-white);
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-company {
    color: var(--ci-golden);
    font-weight: 600;
    font-size: 0.95rem;
    max-width: 250px;
    min-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Auth Modal */
.auth-modal-content {
    max-width: 400px;
}

.auth-tabs {
    display: flex;
    gap: 0;
}

.auth-tab {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--ci-blue);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.auth-tab:hover {
    color: var(--ci-navy);
}

.auth-tab.active {
    color: var(--ci-navy);
    border-bottom-color: var(--ci-golden);
}

/* Auth Forms */
.auth-form {
    padding: 0.5rem 0;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--ci-navy);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--ci-border);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--ci-navy);
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--ci-teal);
}

.form-group input::placeholder {
    color: #9ca8b3;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

/* Auth Errors */
.auth-error {
    background: #fef0ed;
    border: 1px solid #fdd5ce;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    color: var(--ci-error-text);
    font-size: 0.9rem;
}

/* Mobile responsive for auth */
@media (max-width: 600px) {
    .header-actions {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }

    .header-content {
        position: relative;
        padding-top: 2.5rem;
    }

    .user-menu {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }

    .user-company {
        max-width: 150px;
        min-width: 60px;
        font-size: 0.85rem;
    }

    .btn-login,
    .btn-logout,
    .user-menu .btn-history {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .auth-modal-content {
        max-width: 100%;
    }

    .auth-tab {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* ============== Download Dropdown ============== */

.download-dropdown {
    position: relative;
    display: inline-block;
}

.download-dropdown .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.download-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--ci-white);
    border: 1px solid var(--ci-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 100;
    overflow: hidden;
}

.download-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    font-size: 0.95rem;
    color: var(--ci-navy);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.download-option:hover {
    background: var(--ci-light-bg);
}

.download-option:first-child {
    border-bottom: 1px solid var(--ci-border);
}

.option-icon {
    font-size: 1.1rem;
}

.option-badge {
    margin-left: auto;
    padding: 0.15rem 0.5rem;
    background: var(--ci-golden);
    color: var(--ci-navy);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Mobile responsive for dropdown */
@media (max-width: 600px) {
    .download-menu {
        min-width: 180px;
    }

    .download-option {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .option-badge {
        font-size: 0.6rem;
        padding: 0.1rem 0.4rem;
    }
}

/* ============== Login Prompt (Logged Out State) ============== */

.login-prompt {
    background: var(--ci-white);
    border: 2px dashed var(--ci-border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
}

.login-prompt-content {
    max-width: 400px;
    margin: 0 auto;
}

.login-prompt-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-prompt h2 {
    font-size: 1.5rem;
    color: var(--ci-navy);
    margin-bottom: 0.75rem;
}

.login-prompt p {
    color: var(--ci-blue);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

@media (max-width: 600px) {
    .login-prompt {
        padding: 2rem 1rem;
    }

    .login-prompt h2 {
        font-size: 1.25rem;
    }

    .login-prompt p {
        font-size: 0.9rem;
    }

    .btn-large {
        padding: 0.85rem 1.5rem;
        font-size: 1rem;
    }
}

/* ============== Benchmark Comparison Section ============== */

.benchmark-section {
    background: var(--ci-white);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--ci-border);
}

.benchmark-section h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--ci-navy);
}

.benchmark-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--ci-border);
}

.benchmark-ready {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.benchmark-ready.ready-no {
    background: #fef0ed;
    color: var(--ci-coral);
    border: 1px solid #fdd5ce;
}

.benchmark-ready.ready-caveats {
    background: #fef8ed;
    color: var(--ci-warning-text);
    border: 1px solid #fde5c2;
}

.benchmark-ready.ready-yes {
    background: #e6f7f5;
    color: #1a7a6d;
    border: 1px solid #b8e8e3;
}

.benchmark-ready.ready-strong {
    background: #e6f4f8;
    color: var(--ci-teal);
    border: 1px solid #b8dce8;
}

.benchmark-stage-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.benchmark-stage {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--ci-navy);
}

.typical-raise {
    font-size: 0.9rem;
    color: var(--ci-blue);
}

.benchmark-assessment {
    color: var(--ci-blue);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Benchmark Comparisons */
.benchmark-comparisons {
    margin-bottom: 1.5rem;
}

.benchmark-comparisons h4 {
    font-size: 0.9rem;
    color: var(--ci-navy);
    margin-bottom: 0.5rem;
}

.benchmark-legend {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--ci-blue);
    border-bottom: 1px solid var(--ci-border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-marker {
    display: inline-block;
}

.legend-marker.you {
    width: 10px;
    height: 10px;
    background: var(--ci-coral);
    border-radius: 50%;
}

.legend-marker.median {
    width: 12px;
    height: 3px;
    background: var(--ci-golden);
    border-radius: 1px;
}

.legend-marker.top {
    width: 12px;
    height: 3px;
    background: var(--ci-light-teal);
    border-radius: 1px;
}

.benchmark-comparison-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.comp-label {
    min-width: 120px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ci-navy);
    padding-top: 0.25rem;
}

.comp-chart-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comp-bar-container {
    height: 24px;
    background: var(--ci-light-bg);
    border-radius: 4px;
    position: relative;
    border: 1px solid var(--ci-border);
}

.comp-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--ci-border);
    transform: translateY(-50%);
    border-radius: 2px;
}

.comp-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
}

.comp-marker {
    position: absolute;
    top: 2px;
    width: 3px;
    height: 20px;
    transform: translateX(-50%);
    border-radius: 1px;
}

.comp-marker.median {
    background: var(--ci-golden);
}

.comp-marker.top {
    background: var(--ci-light-teal);
}

.comp-marker .marker-label {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--ci-hint-text);
    white-space: nowrap;
}

.comp-your-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.comp-your-marker::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background: var(--ci-coral);
    border-radius: 50%;
    border: 2px solid var(--ci-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.your-score-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ci-coral);
    white-space: nowrap;
    text-shadow: 0 0 3px var(--ci-white);
}

.comp-scale {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0.25rem 0;
    font-size: 0.7rem;
    color: var(--ci-hint-text);
}

.scale-mid {
    position: relative;
    left: 0;
}

.comp-percentile {
    min-width: 110px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    text-align: center;
    align-self: flex-start;
    margin-top: 0.25rem;
}

.comp-percentile.top-quartile {
    background: #e6f7f5;
    color: #1a7a6d;
    border: 1px solid #b8e8e3;
}

.comp-percentile.above-median {
    background: #e6f4f8;
    color: var(--ci-teal);
    border: 1px solid #b8dce8;
}

.comp-percentile.below-median {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

.comp-percentile.below-minimum {
    background: #fef0ed;
    color: var(--ci-coral);
    border: 1px solid #fdd5ce;
}

/* Gap Analysis */
.benchmark-gaps {
    margin-bottom: 1.5rem;
}

.benchmark-gaps h4 {
    font-size: 0.9rem;
    color: var(--ci-navy);
    margin-bottom: 0.75rem;
}

.gap-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.gap-item.critical {
    background: #fef0ed;
    border-left: 3px solid var(--ci-coral);
}

.gap-item.high {
    background: #fef8ed;
    border-left: 3px solid var(--ci-golden);
}

.gap-item.medium {
    background: var(--ci-light-bg);
    border-left: 3px solid var(--ci-blue);
}

.gap-metric {
    min-width: 140px;
    font-weight: 500;
    color: var(--ci-navy);
}

.gap-current {
    color: var(--ci-blue);
}

.gap-arrow {
    color: var(--ci-hint-text);
}

.gap-target {
    color: var(--ci-navy);
    font-weight: 500;
}

.gap-delta {
    margin-left: auto;
    font-weight: 600;
    color: var(--ci-teal);
}

/* Benchmark Actions */
.benchmark-actions {
    margin-bottom: 1.5rem;
}

.benchmark-actions h4 {
    font-size: 0.9rem;
    color: var(--ci-navy);
    margin-bottom: 0.75rem;
}

.benchmark-actions ol {
    padding-left: 1.5rem;
}

.benchmark-actions li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--ci-blue);
}

/* Success Factors */
.success-factors {
    border-top: 1px solid var(--ci-border);
    padding-top: 1rem;
}

.success-factors summary {
    cursor: pointer;
    color: var(--ci-blue);
    font-size: 0.9rem;
}

.success-factors summary:hover {
    color: var(--ci-navy);
}

.success-factors ul {
    margin-top: 0.75rem;
    padding-left: 1.5rem;
}

.success-factors li {
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--ci-blue);
}

/* Benchmark Section Responsive */
@media (max-width: 600px) {
    .benchmark-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .benchmark-legend {
        flex-wrap: wrap;
        gap: 0.75rem 1.25rem;
    }

    .benchmark-comparison-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .comp-label {
        min-width: 100%;
        padding-top: 0;
    }

    .comp-chart-wrapper {
        width: 100%;
    }

    .comp-bar-container {
        height: 28px;
    }

    .your-score-label {
        font-size: 0.8rem;
        top: -20px;
    }

    .comp-marker .marker-label {
        font-size: 0.6rem;
    }

    .comp-percentile {
        min-width: auto;
        align-self: flex-start;
    }

    .gap-item {
        flex-wrap: wrap;
    }

    .gap-metric {
        min-width: 100%;
        margin-bottom: 0.25rem;
    }
}
