:root {
    color-scheme: light;
    --ink: #202124;
    --muted: #686f7a;
    --line: #dfe3e8;
    --panel: #ffffff;
    --page: #f6f7f9;
    --nav: #24272b;
    --nav-active: #f0c36a;
    --green: #18794e;
    --green-bg: #e9f7ef;
    --amber: #9a5b00;
    --amber-bg: #fff4d6;
    --red: #b3261e;
    --red-bg: #fdecea;
    --cyan: #006d77;
    --cyan-bg: #e2f5f7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

a {
    color: var(--cyan);
    text-decoration: none;
}

.shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--nav);
    color: #fff;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 4px 22px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--nav-active);
    color: #211a09;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #c8cdd3;
    margin-top: 3px;
}

nav {
    display: grid;
    gap: 4px;
}

nav a {
    color: #e8ebef;
    padding: 10px 12px;
    border-radius: 6px;
}

nav a:hover,
nav a.active {
    background: #34383d;
    color: #fff;
}

nav a.active {
    border-left: 3px solid var(--nav-active);
}

.main {
    min-width: 0;
    padding: 28px;
}

.topbar,
.section-head,
.toolbar,
.run-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h1,
.run-header h2,
.section-head h2 {
    margin: 0;
}

.topbar h1 {
    font-size: 28px;
    line-height: 1.2;
}

.run-header h2,
.section-head h2 {
    font-size: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
}

.mode-pill,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.mode-pill {
    background: var(--cyan-bg);
    color: var(--cyan);
    border: 1px solid #a7dce2;
}

.badge-green {
    background: var(--green-bg);
    color: var(--green);
}

.badge-amber {
    background: var(--amber-bg);
    color: var(--amber);
}

.badge-red {
    background: var(--red-bg);
    color: var(--red);
}

.badge-neutral {
    background: #edf0f3;
    color: #4f5863;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.metric-grid.short {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.metric-card span {
    color: var(--muted);
    display: block;
    margin-bottom: 8px;
}

.metric-card strong {
    display: block;
    font-size: 24px;
    line-height: 1.1;
}

.provider-strip {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.provider-strip span,
.provider-strip small {
    display: block;
    color: var(--muted);
}

.provider-strip strong {
    display: block;
    margin: 4px 0;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
    gap: 20px;
}

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

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

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: #f0f2f4;
    color: #3b4149;
    font-size: 12px;
    text-transform: uppercase;
}

td {
    color: #2d333a;
}

tr:hover td {
    background: #fafbfc;
}

.toolbar input,
.mapping-form input,
.mapping-form select {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cfd5dc;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #fff;
}

.search-form {
    display: flex;
    gap: 10px;
    width: min(560px, 100%);
}

.search-form input {
    max-width: none;
}

.toolbar input {
    max-width: 420px;
}

.button {
    appearance: none;
    border: 0;
    min-height: 38px;
    padding: 9px 14px;
    border-radius: 6px;
    background: var(--cyan);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    background: #00545d;
}

.button:disabled {
    background: #9aa3ad;
    cursor: not-allowed;
}

.button.secondary {
    background: #4f5863;
}

.button.secondary:hover {
    background: #3b4149;
}

.text-link {
    font-weight: 700;
}

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

.pagination {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}

.form-band {
    background: var(--panel);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 18px;
    margin-bottom: 24px;
}

td small {
    color: var(--muted);
}

.line-item {
    display: block;
    white-space: nowrap;
}

.preview-header {
    margin-top: 24px;
}

.preview-table {
    margin-bottom: 22px;
}

.mapping-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(160px, 1fr));
    gap: 14px;
    align-items: end;
}

.mapping-form label {
    color: #3b4149;
    font-weight: 700;
    display: grid;
    gap: 6px;
}

.field-wide {
    grid-column: span 2;
    display: grid;
    gap: 8px;
}

.field-wide > label {
    color: #3b4149;
    font-weight: 700;
}

.multi-select {
    background: #fff;
    border: 1px solid #cfd5dc;
    border-radius: 6px;
    max-height: 152px;
    overflow: auto;
    padding: 8px;
    display: grid;
    gap: 4px;
}

.multi-select label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    min-height: 28px;
}

.multi-select input {
    width: auto;
    min-height: auto;
}

.mapping-form .check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
}

.mapping-form .check input {
    width: auto;
    min-height: auto;
}

.exception-list {
    display: grid;
    gap: 10px;
}

.exception-list article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: grid;
    gap: 7px;
}

.exception-list strong {
    line-height: 1.35;
}

.exception-list small,
.empty {
    color: var(--muted);
}

.flash {
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--green-bg);
    color: var(--green);
    font-weight: 700;
}

.flash.error {
    background: var(--red-bg);
    color: var(--red);
}

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .main {
        padding: 18px;
    }

    .metric-grid,
    .metric-grid.short,
    .split,
    .mapping-form {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-head,
    .toolbar,
    .run-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .toolbar input {
        max-width: none;
    }
}
