.tc-statement-form,
.tc-statement-report {
    display: grid;
    gap: 1.25rem;
    min-width: 0;
}

.tc-statement-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .625rem;
}

.tc-statement-report {
    --statement-surface: #fff;
    --statement-subtle: #f8fafc;
    --statement-border: #e2e8f0;
    --statement-muted: #526175;
    --statement-accent: #1d4ed8;
    --statement-accent-surface: #eff6ff;
    --statement-accent-border: #bfdbfe;
    container-type: inline-size;
}

.dark .tc-statement-report {
    --statement-surface: #18181b;
    --statement-subtle: #202126;
    --statement-border: #303137;
    --statement-muted: #a1a1aa;
    --statement-accent: #93c5fd;
    --statement-accent-surface: #17243b;
    --statement-accent-border: #28446d;
}

.tc-statement-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

.tc-statement-metric {
    display: grid;
    align-content: start;
    gap: .25rem;
    min-width: 0;
    padding: .875rem 1rem;
    border: 1px solid var(--statement-border);
    border-radius: .65rem;
    background: var(--statement-subtle);
}

.tc-statement-metric--closing {
    background: var(--statement-accent-surface);
    border-color: var(--statement-accent-border);
}

.tc-statement-metric dt,
.tc-statement-secondary,
.tc-statement-note,
.tc-statement-empty {
    color: var(--statement-muted);
    font-size: .8125rem;
}

.tc-statement-metric dt,
.tc-statement-results-header h3 {
    font-weight: 600;
}

.tc-statement-number {
    font-size: 1.125rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.tc-statement-number small {
    color: var(--statement-muted);
    font-size: .7em;
}

.tc-statement-metric--closing .tc-statement-number {
    color: var(--statement-accent);
}

.tc-statement-note {
    margin-top: .75rem;
}

.tc-statement-results {
    min-width: 0;
    border: 1px solid var(--statement-border);
    border-radius: .75rem;
    background: var(--statement-surface);
}

.tc-statement-results-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .75rem;
    padding: .875rem 1rem;
}

.tc-statement-table-scroll {
    overflow-x: auto;
}

.tc-statement-table-scroll:focus-visible {
    outline: 2px solid var(--statement-accent);
    outline-offset: -2px;
}

.tc-statement-table {
    width: 100%;
    min-width: 41rem;
    border-collapse: collapse;
    font-size: .875rem;
}

.tc-statement-table th,
.tc-statement-table td {
    padding: .65rem 1rem;
    border-top: 1px solid var(--statement-border);
    text-align: start;
    vertical-align: top;
}

.tc-statement-table th {
    background: var(--statement-subtle);
    font-weight: 600;
    white-space: nowrap;
}

.tc-statement-table .tc-statement-amount {
    text-align: end;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.tc-statement-date {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.tc-statement-detail {
    min-width: 10rem;
    overflow-wrap: anywhere;
}

.tc-statement-detail .tc-statement-secondary {
    margin-top: .125rem;
}

.tc-statement-balance {
    color: var(--statement-accent);
    font-weight: 650;
}

.tc-statement-empty {
    padding: 1rem;
    border-top: 1px solid var(--statement-border);
}

.tc-statement-error {
    color: #b91c1c;
    font-size: .875rem;
}

.dark .tc-statement-error {
    color: #fca5a5;
}

@container (min-width: 46rem) {
    .tc-statement-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@container (max-width: 24rem) {
    .tc-statement-metric { padding: .65rem .75rem; }
}

.tc-grain-report-print-header {
    display: none;
}

@media print {
    body:has(.tc-statement-report) .fi-sidebar,
    body:has(.tc-statement-report) .fi-topbar,
    body:has(.tc-statement-report) .fi-breadcrumbs,
    .tc-statement-controls { display: none !important; }

    .tc-statement-report,
    .dark .tc-statement-report {
        --statement-surface: white;
        --statement-subtle: white;
        --statement-border: #bbb;
        --statement-muted: #444;
        --statement-accent: #111;
        --statement-accent-surface: white;
        --statement-accent-border: #777;
        color: #111;
        background: white;
    }

    .tc-statement-report .fi-section { color: #111; background: white; box-shadow: none; }
    .tc-statement-report .fi-section-header-heading,
    .tc-statement-report .fi-section-header-description,
    .tc-statement-report .fi-badge { color: #111; }
    .tc-statement-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .tc-statement-table-scroll { overflow: visible; }
    .tc-statement-table { min-width: 0; font-size: 9pt; }
    .tc-statement-table th, .tc-statement-table td { padding: .35rem .45rem; }
    .tc-statement-table thead { display: table-header-group; }
    .tc-statement-table tr { break-inside: avoid; }

    body:has(.tc-grain-contract-report) .fi-header,
    .tc-grain-report-screen-organization { display: none !important; }

    .tc-grain-report-print-header {
        display: flex;
        align-items: center;
        gap: .6rem;
        padding: .25rem 0 .5rem;
        border-bottom: 1px solid #999;
        break-inside: avoid;
        break-after: avoid;
    }

    .tc-grain-report-print-logo {
        width: auto;
        max-width: 25mm;
        max-height: 12mm;
        object-fit: contain;
    }

    .tc-grain-report-print-header strong { display: block; font-size: 11pt; }
    .tc-grain-report-print-header span { display: block; margin-top: .2rem; font-size: 8pt; }

    .tc-grain-contract-report { gap: .65rem; font-size: 8pt; line-height: 1; }

    .tc-grain-contract-report :is(.fi-section, .tc-statement-results) {
        border: 1px solid #999;
    }

    .tc-grain-contract-report :is(.fi-section-header, .fi-section-content, .tc-statement-results-header, .tc-statement-empty) {
        padding: .4rem .55rem;
    }

    .tc-grain-contract-report .tc-statement-metrics { gap: .35rem; }
    .tc-grain-contract-report .tc-statement-metric { padding: .3rem .4rem; }
    .tc-grain-contract-report .tc-statement-note { margin-top: .4rem; }

    .tc-grain-contract-report .fi-section-header-heading,
    .tc-grain-contract-report .tc-statement-results-header h3 { font-size: 8.5pt; line-height: 1; }
    .tc-grain-contract-report .tc-statement-number { font-size: 8.5pt; line-height: 1; }
    .tc-grain-contract-report .tc-statement-table { font-size: 7pt; line-height: 1; }
    .tc-grain-contract-report .tc-statement-table :is(th, td) { padding-block: .25rem; }
    .tc-grain-contract-report .fi-section-header-description,
    .tc-grain-contract-report .tc-statement-metric dt,
    .tc-grain-contract-report .tc-statement-secondary,
    .tc-grain-contract-report .tc-statement-note,
    .tc-grain-contract-report .tc-statement-empty { font-size: 7pt; line-height: 1; }
}
