﻿@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --ws-blue: #4a7fa8;
    --ws-blue-dark: #335f80;
    --ws-blue-light: #c4d4e6;
    --ws-blue-pale: #eef4f9;
    --ws-blue-soft: #f6f9fc;
    --ws-text: #1f2f3f;
    --ws-text-muted: #607487;
    --ws-border: #d9e4ee;
    --ws-border-strong: #c7d6e4;
    --ws-bg: #f4f7fa;
    --ws-white: #ffffff;
    --ws-total-bg: #3a6585;
    --ws-shadow: 0 6px 18px rgba(35, 56, 80, 0.06);
    --ws-radius: 10px;
    --ws-radius-sm: 8px;
    --font-ui: 'Inter', sans-serif;
    --font-num: 'JetBrains Mono', monospace;
}

/* ============================================================
   BASE
   ============================================================ */
html, body {
    font-family: var(--font-ui);
    color: var(--ws-text);
    background: var(--ws-bg);
}

/* ============================================================
   GENERIC AI HTML SUPPORT
   ============================================================ */
.ai-html-content {
    font-family: var(--font-ui);
    color: var(--ws-text);
    padding: 18px 20px 22px;
    background: var(--ws-bg);
}

    .ai-html-content > *:first-child {
        margin-top: 0 !important;
    }

    .ai-html-content > *:last-child {
        margin-bottom: 0 !important;
    }

/* ============================================================
   HEADERS / TEXT
   ============================================================ */
:is(.workspace-report, .ai-html-content) h1,
:is(.workspace-report, .ai-html-content) h2,
:is(.workspace-report, .ai-html-content) h3,
:is(.workspace-report, .ai-html-content) h4 {
    font-family: var(--font-ui);
    color: var(--ws-text);
    line-height: 1.2;
    margin-top: 0;
    letter-spacing: -0.02em;
}

:is(.workspace-report, .ai-html-content) h1 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 14px;
}

:is(.workspace-report, .ai-html-content) h2 {
    font-size: 22px;
    font-weight: 800;
    padding: 12px;
    margin-bottom: 12px;
}

:is(.workspace-report, .ai-html-content) h3 {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--ws-blue-dark);
}

:is(.workspace-report, .ai-html-content) h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--ws-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

:is(.workspace-report, .ai-html-content) p {
    font-size: 12.5px;
    line-height: 1.6;
    color: #5d7186;
    margin: 0 0 12px 0;
}

:is(.workspace-report, .ai-html-content) strong {
    color: var(--ws-text);
    font-weight: 700;
}

:is(.workspace-report, .ai-html-content) em {
    color: var(--ws-text-muted);
}

:is(.workspace-report, .ai-html-content) hr {
    border: 0;
    border-top: 1px solid var(--ws-border);
    margin: 18px 0;
}

/* ============================================================
   LISTS
   ============================================================ */
:is(.workspace-report, .ai-html-content) ul,
:is(.workspace-report, .ai-html-content) ol {
    margin: 0 0 10px 0;
    padding-left: 20px;
}

:is(.workspace-report, .ai-html-content) li {
    font-size: 13.5px;
    line-height: 1.65;
    color: #3f5368;
    margin-bottom: 6px;
}

/* ============================================================
   TABLES
   ============================================================ */
:is(.workspace-report, .ai-html-content) table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--ws-white);
    border: 1px solid #dce6ef;
    border-radius: 6px;
    overflow: hidden;
    margin: 0;
    box-shadow: none;
}

    :is(.workspace-report, .ai-html-content) table thead tr {
        background: #edf3f8;
    }

    :is(.workspace-report, .ai-html-content) table thead th {
        padding: 8px 16px;
        font-size: 9.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: #73869a;
        border-bottom: 1px solid #dce6ef;
        text-align: left;
        white-space: nowrap;
    }

        :is(.workspace-report, .ai-html-content) table thead th:not(:first-child) {
            text-align: right;
        }

    :is(.workspace-report, .ai-html-content) table tbody tr {
        background: var(--ws-white);
    }

        :is(.workspace-report, .ai-html-content) table tbody tr:hover {
            background: #f9fbfd;
        }

    :is(.workspace-report, .ai-html-content) table tbody td {
        padding: 9px 16px;
        font-size: 12.5px;
        color: #24384a;
        border-bottom: 1px solid #edf3f8;
        vertical-align: middle;
    }

        :is(.workspace-report, .ai-html-content) table tbody td:not(:first-child) {
            text-align: right;
            font-family: var(--font-num);
            font-variant-numeric: tabular-nums;
        }

    :is(.workspace-report, .ai-html-content) table tbody tr:last-child td {
        border-bottom: none;
    }

:is(.workspace-report, .ai-html-content) .totals-row td,
:is(.workspace-report, .ai-html-content) tr.total-row td {
    background: #446f93;
    color: var(--ws-white);
    font-weight: 700;
    font-size: 13px;
    border-bottom: none;
}

/* ---------- HIERARCHY ROWS (category > sub-account > sub-sub-account) ---------- */
/* Some models (e.g. Claude) emit class names like level-0/1/2 to convey the
   account hierarchy in an income statement. Give them a consistent look so
   they don't fall back to undifferentiated browser styling. */
:is(.workspace-report, .ai-html-content) tr.level-0 td {
    background: #eef4f9;
    font-weight: 700;
    color: var(--ws-blue-dark);
}

:is(.workspace-report, .ai-html-content) tr.level-1 td:first-child {
    padding-left: 28px;
}

:is(.workspace-report, .ai-html-content) tr.level-2 td:first-child {
    padding-left: 44px;
    color: #5d7186;
}

:is(.workspace-report, .ai-html-content) td.indent-1 {
    padding-left: 28px !important;
}

:is(.workspace-report, .ai-html-content) td.indent-2 {
    padding-left: 44px !important;
}

/* account-label is the first column in income-statement-style tables — already
   left-aligned by default, but make it explicit so a model emitting it gets
   the expected look regardless of column position. */
:is(.workspace-report, .ai-html-content) td.account-label,
:is(.workspace-report, .ai-html-content) th.account-label {
    text-align: left;
    font-family: var(--font-ui);
}

    :is(.workspace-report, .ai-html-content) .totals-row td:first-child,
    :is(.workspace-report, .ai-html-content) tr.total-row td:first-child {
        font-family: var(--font-ui);
        letter-spacing: 0.02em;
    }

    :is(.workspace-report, .ai-html-content) tr.total-row td:not(:first-child) {
        font-family: var(--font-num);
    }

/* ============================================================
   NUMERIC HELPERS
   ============================================================ */
.num,
.metric-value,
.margin-badge,
:is(.workspace-report, .ai-html-content) td:not(:first-child),
:is(.workspace-report, .ai-html-content) th.num,
:is(.workspace-report, .ai-html-content) td.num {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
}

:is(.workspace-report, .ai-html-content) .text-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

:is(.workspace-report, .ai-html-content) th.text-numeric {
    text-align: right;
}

:is(.workspace-report, .ai-html-content) td.text-numeric {
    text-align: right;
}

:is(.workspace-report, .ai-html-content) th {
    text-align: left;
    font-weight: 600;
}

/* ============================================================
   BADGES
   ============================================================ */
.margin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: #deedf9;
    color: var(--ws-blue-dark);
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #c9dff0;
}

/* ============================================================
   WORKSPACE REPORT WRAPPER
   ============================================================ */
.workspace-report {
    font-family: var(--font-ui);
    color: var(--ws-text);
    background: var(--ws-bg);
    min-height: 100%;
}

    /* ---------- HEADER ---------- */
    .workspace-report .report-header {
        background: #4f82aa;
        padding: 18px 20px 18px;
        border-bottom: none;
    }

        .workspace-report .report-header h1,
        .workspace-report .report-header h2,
        .workspace-report .report-header h3 {
            color: #fff !important;
            margin: 0 0 4px 0;
            font-size: 18px;
            font-weight: 700;
            letter-spacing: -0.01em;
        }

        .workspace-report .report-header .report-scope {
            display: flex;
            flex-wrap: wrap;
            gap: 10px 16px;
            margin-top: 8px;
            color: #ffffff !important;
            font-size: 12px;
            line-height: 1.45;
            font-weight: 500;
            opacity: 1;
        }

        /* Some models (Claude in particular) emit Company / Period lines as
           loose <p> tags directly inside .report-header instead of wrapping
           them in .report-scope. Without these rules they fall back to black
           text on the blue banner. */
        :is(.workspace-report, .ai-html-content) .report-header > p {
            color: #ffffff !important;
            margin: 4px 0;
            font-size: 12px;
            line-height: 1.45;
            font-weight: 500;
            opacity: 1;
        }

        :is(.workspace-report, .ai-html-content) .report-header > p:first-of-type {
            margin-top: 8px;
        }

        :is(.workspace-report, .ai-html-content) .report-header > p strong {
            color: #ffffff !important;
            font-weight: 700;
        }

            .workspace-report .report-header .report-scope span,
            .workspace-report .report-header .report-scope div,
            .workspace-report .report-header .report-scope p {
                display: inline-flex;
                align-items: center;
                gap: 6px;
                color: #ffffff !important;
                font-size: 12px;
                line-height: 1.45;
                font-weight: 500;
                margin: 0;
            }

                .workspace-report .report-header .report-scope strong,
                .workspace-report .report-header .report-scope p strong {
                    color: #ffffff !important;
                    font-weight: 700;
                }

    /* ---------- REPORT META ---------- */
    .workspace-report .report-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        padding: 8px 20px;
        background: #edf3f8;
        border-bottom: 1px solid #dce6ef;
        font-size: 11.5px;
        color: #72859a;
    }

        .workspace-report .report-meta strong {
            color: #557796;
            font-weight: 700;
        }

    /* ---------- REPORT BODY ---------- */
    .workspace-report .report-body {
        padding: 18px 20px 22px;
        gap: 14px;
    }

    /* ---------- METRIC CARDS ---------- */
    .workspace-report .metrics-row {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
        align-items: start;
    }

        .workspace-report .metrics-row > .metric-card:last-child:nth-child(odd) {
            max-width: 320px;
        }

    .workspace-report .metric-card {
        background: var(--ws-white);
        border: 1px solid #dce6ef;
        border-radius: 6px;
        padding: 14px 16px;
        min-height: 68px;
        box-shadow: none;
    }

    .workspace-report .metric-label {
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #8a9aab;
        margin-bottom: 7px;
    }

    .workspace-report .metric-value {
        font-family: var(--font-num);
        font-size: 18px;
        line-height: 1;
        font-weight: 600;
        color: #24384a;
    }

    .workspace-report .metric-subtext {
        font-size: 10.5px;
        margin-top: 4px;
        color: #7c8ea0;
    }

    /* ---------- SECTION CONTAINERS ---------- */
    .workspace-report .content-section,
    .workspace-report .detail-section,
    .workspace-report .summary-card,
    .workspace-report .insights-section,
    .ai-html-content .content-section,
    .ai-html-content .detail-section,
    .ai-html-content .insights-section {
        background: #fff;
        border: 1px solid #dce6ef;
        border-radius: 6px;
        box-shadow: none;
        overflow: hidden;
    }

        .workspace-report .content-section .section-header,
        .workspace-report .detail-section .section-header,
        .workspace-report .summary-card .card-header,
        .workspace-report .insights-section h3,
        .ai-html-content .section-header,
        .ai-html-content .insights-section h3,
        .ai-html-content > h3 {
            background: #edf3f8;
            color: #4d7394;
            border-bottom: 1px solid #dce6ef;
            padding: 10px 16px;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0;
            margin: 0;
        }

.ai-html-content > h3 {
    border: 1px solid #dce6ef;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
}

    .ai-html-content > h3 + table,
    .ai-html-content > h3 + .table-container table,
    .ai-html-content > h3 + ul,
    .ai-html-content > h3 + p {
        margin-top: 0;
    }

.workspace-report .content-section .section-body,
.workspace-report .summary-card .card-body {
    padding: 14px 16px;
}

    .workspace-report .content-section .section-body p,
    .workspace-report .summary-note,
    .ai-html-content .summary-note {
        font-size: 12.5px;
        color: var(--ws-text-muted);
        margin-top: 8px;
        margin-bottom: 0;
    }

.workspace-report .detail-section table {
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* ---------- SUMMARY GRID ---------- */
.workspace-report .summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ---------- INSIGHTS ---------- */
.workspace-report .insights-section,
.ai-html-content .insights-section {
    margin-top: 10px;
}

    .workspace-report .insights-section h3,
    .ai-html-content .insights-section h3 {
        /* already covered by shared selector above */
    }

    .workspace-report .insights-section ul,
    .ai-html-content .insights-section ul {
        padding: 14px 18px 16px 30px;
        margin: 0;
        list-style: disc;
    }

    .workspace-report .insights-section li,
    .ai-html-content .insights-section li {
        font-size: 12.5px;
        line-height: 1.65;
        color: #42576b;
        margin-bottom: 10px;
    }

        .workspace-report .insights-section li:last-child,
        .ai-html-content .insights-section li:last-child {
            margin-bottom: 0;
        }

        .workspace-report .insights-section li::marker {
            color: #4a7fa8;
        }

/* ============================================================
   AI HTML CONTENT — FIRST HEADING BANNER
   ============================================================ */
.ai-html-content > h1:first-child,
.ai-html-content > h2:first-child {
    background: #4f82aa;
    color: #fff !important;
    margin: -18px -20px 0 -20px;
    padding: 18px 20px 8px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

    .ai-html-content > h1:first-child + p,
    .ai-html-content > h2:first-child + p {
        background: #4f82aa;
        color: #ffffff !important;
        opacity: 1;
        margin: 0 -20px 14px -20px;
        padding: 0 20px 14px;
        font-size: 12px;
        line-height: 1.45;
        font-weight: 500;
    }

        .ai-html-content > h1:first-child + p strong,
        .ai-html-content > h2:first-child + p strong {
            color: #ffffff !important;
            font-weight: 700;
        }

/* ============================================================
   TAB BAR
   ============================================================ */
.workspace-tabs-bar {
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 32px;
    padding: 0 6px;
    background: #fff;
    border-bottom: 1px solid #dfe8f0;
    overflow-x: auto;
    scrollbar-width: none;
}

    .workspace-tabs-bar::-webkit-scrollbar {
        display: none;
    }

.workspace-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 290px;
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 500;
    color: #6d8093;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    user-select: none;
    white-space: nowrap;
}

    .workspace-tab:hover {
        background: #f8fbfd;
        color: #3a6585;
    }

    .workspace-tab.active {
        background: transparent;
        color: #3a6585;
        border-bottom: 2px solid #4a7fa8;
        box-shadow: none;
        font-weight: 600;
    }

    .workspace-tab .tab-title {
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 235px;
    }

    .workspace-tab .tab-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 15px;
        height: 15px;
        border: none;
        background: transparent;
        color: #97a8b8;
        border-radius: 3px;
        font-size: 11px;
        cursor: pointer;
        padding: 0;
        flex-shrink: 0;
    }

        .workspace-tab .tab-close:hover {
            background: #edf4fa;
            color: #3a6585;
        }

/* ============================================================
   TAB CONTENT
   ============================================================ */
.workspace-tab-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: #f4f7fa;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.workspace-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px 24px;
    text-align: center;
}

    .workspace-empty h3 {
        color: var(--ws-blue-dark);
        margin-bottom: 8px;
    }

    .workspace-empty p {
        color: var(--ws-text-muted);
        max-width: 340px;
    }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .workspace-report .metrics-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .workspace-report .report-header {
        padding: 16px 16px 14px;
    }

    .workspace-report .report-body,
    .ai-html-content {
        padding: 14px 16px 18px;
    }

    .workspace-report .metrics-row {
        grid-template-columns: 1fr;
    }

    .workspace-report .metric-card {
        max-width: none;
    }

    .workspace-report .report-header .report-scope {
        gap: 6px 12px;
        font-size: 11.5px;
    }

    .ai-html-content > h1:first-child,
    .ai-html-content > h2:first-child {
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

        .ai-html-content > h1:first-child + p,
        .ai-html-content > h2:first-child + p {
            margin-left: -16px;
            margin-right: -16px;
            padding-left: 16px;
            padding-right: 16px;
        }
}
