:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --ink: #172026;
    --muted: #5c6972;
    --line: #d9e0e4;
    --panel: #ffffff;
    --accent: #256f74;
    --accent-dark: #19555a;
    --warn: #9b5b00;
    --ok: #116b3a;
    --bad: #9b2c2c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.page-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: clamp(32px, 4vw, 52px);
    line-height: 1.05;
}

.version {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.version-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid #b8d7d9;
    border-radius: 6px;
    background: #eef8f8;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

h2 {
    font-size: 22px;
}

.panel,
.notice,
.metadata,
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel {
    padding: 20px;
}

.panel-heading,
.heading-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.panel-heading {
    justify-content: space-between;
    margin-bottom: 16px;
}

.notice {
    margin-bottom: 16px;
    padding: 14px 16px;
}

.error {
    border-color: #efb4b4;
    color: var(--bad);
}

.import-note {
    margin-bottom: 12px;
    border-color: #b8d7d9;
    color: #24496e;
}

.metadata {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding: 14px 16px;
    color: var(--muted);
    font-size: 13px;
}

.metadata strong {
    color: var(--ink);
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 16px;
    align-items: end;
}

.upload-grid-wide {
    grid-template-columns: repeat(5, minmax(150px, 1fr)) auto;
}

.upload-grid-stacked {
    grid-template-columns: minmax(260px, 520px);
    align-items: stretch;
}

.upload-grid-stacked .form-actions {
    align-self: start;
}

label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

input[type="file"] {
    width: 100%;
    min-height: 43px;
    padding: 9px;
    background: #fbfcfc;
    border: 1px solid var(--line);
    border-radius: 6px;
}

button,
.download,
.secondary-button {
    min-height: 43px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

button:hover,
.download:hover {
    background: var(--accent-dark);
}

.secondary-button {
    background: #eef3f3;
    color: var(--ink);
    border: 1px solid var(--line);
}

.secondary-button:hover {
    background: #dfe8e8;
}

.form-actions,
.section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.form-actions {
    align-self: end;
}

.results {
    margin-top: 28px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.filter {
    min-height: 34px;
    padding: 0 11px;
    background: #eef3f3;
    color: var(--ink);
    border: 1px solid var(--line);
    font-size: 13px;
}

.filter:hover,
.filter.active {
    background: var(--accent);
    color: #fff;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1900px;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.status {
    display: inline-flex;
    max-width: 190px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.auto_matched {
    background: #ddf3e6;
    color: var(--ok);
}

.needs_review {
    background: #fff0d4;
    color: var(--warn);
}

.manual_needed,
.partially_allocated,
.fully_reconciled {
    background: #e7eef8;
    color: #24496e;
}

.auto_classified_teya_revenue {
    background: #ddf3e6;
    color: var(--ok);
}

.teya_report_matched {
    background: #ddf3e6;
    color: var(--ok);
}

.incash_matched {
    background: #ddf3e6;
    color: var(--ok);
}

.teya_without_report {
    background: #fff0d4;
    color: var(--warn);
}

.invoice_without_bank_transaction,
.bank_transaction_missing_invoice {
    background: #f8dddd;
    color: var(--bad);
}

.muted {
    color: var(--muted);
}

@media (max-width: 820px) {
    .upload-grid,
    .upload-grid-wide,
    .upload-grid-stacked {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .download {
        width: 100%;
    }

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