:root {
    color-scheme: light;
    --bg: #f5f9fc;
    --panel: #ffffff;
    --ink: #102f3e;
    --muted: #526b78;
    --line: #d5e4ee;
    --line-soft: #edf5f9;
    --navy: #055c9a;
    --navy-dark: #034a78;
    --teal: #055e57;
    --teal-dark: #034c46;
    --teal-soft: #e8f6fb;
    --green: #23843c;
    --red: #e01b24;
    --amber: #f59e0b;
    --advent-blue: #055c9a;
    --advent-cyan: #17a9e0;
    --advent-green: #7ec242;
    --advent-deep-green: #055e57;
    --shadow: 0 10px 22px rgba(5, 92, 154, 0.1);
    font-family: "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 14px;
}

.loading-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 7rem;
    height: 7rem;
    transform: translate(-50%, -50%) rotate(-90deg);
}

.loading-progress circle {
    fill: none;
    stroke: var(--line);
    stroke-width: 0.55rem;
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: var(--advent-blue);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: fixed;
    top: calc(50% + 4.5rem);
    left: 50%;
    color: var(--navy-dark);
    font-size: 13px;
    font-weight: 800;
    transform: translateX(-50%);
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 1000;
    display: none;
    max-width: 720px;
    margin: 0 auto;
    border: 1px solid #f0b1aa;
    border-radius: 6px;
    padding: 12px 44px 12px 14px;
    background: #fff0ef;
    box-shadow: 0 10px 22px rgba(16, 37, 44, 0.14);
    color: #8f1117;
    font-weight: 700;
}

#blazor-error-ui .reload {
    color: var(--advent-blue);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 14px;
    cursor: pointer;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.dashboard-shell {
    width: min(1840px, calc(100vw - 32px));
    margin: 0 auto;
    padding-bottom: 28px;
}

.app-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 calc(50% - 50vw) 14px;
    padding: 10px max(16px, calc((100vw - 1840px) / 2 + 16px));
    color: #ffffff;
    border-bottom: 3px solid var(--advent-green);
    background: linear-gradient(180deg, var(--advent-blue), var(--navy-dark));
    box-shadow: 0 2px 12px rgba(5, 92, 154, 0.28);
}

.brand-lockup,
.app-actions,
.dataset-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo-frame {
    display: flex;
    width: 180px;
    height: 42px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    padding: 5px 10px;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(3, 74, 120, 0.22);
}

.brand-logo {
    display: block;
    width: 100%;
    max-height: 32px;
    object-fit: contain;
}

.brand-lockup h1 {
    font-size: 24px;
    font-weight: 760;
    letter-spacing: 0;
}

.bar-button,
.compare-button {
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 5px;
    padding: 0 18px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
    font-weight: 750;
}

.bar-button:hover {
    background: rgba(255, 255, 255, 0.14);
}

.bar-button.primary,
.compare-button {
    min-width: 154px;
    border-color: transparent;
    background: linear-gradient(180deg, #08786f, var(--advent-deep-green));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.dataset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.dataset-card,
.filter-strip,
.compare-summary,
.comparison-narrative,
.comparison-table-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    box-shadow: 0 1px 3px rgba(16, 37, 44, 0.05);
}

.dataset-card {
    overflow: hidden;
}

.dataset-card-main {
    display: grid;
    grid-template-columns: minmax(320px, 1.05fr) minmax(320px, 0.95fr);
    gap: 22px;
    padding: 16px;
}

.dataset-upload-column {
    min-width: 0;
}

.dataset-badge {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 5px;
    color: #ffffff;
    background: linear-gradient(180deg, var(--advent-blue), var(--navy-dark));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
    font-size: 20px;
    font-weight: 800;
}

.dataset-title-row h2 {
    font-size: 19px;
    line-height: 1.1;
}

.dataset-title-row p {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.field {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.compact-field {
    grid-template-columns: auto minmax(160px, 1fr);
    align-items: center;
    margin-top: 12px;
}

.field > span,
.mapping-heading h3,
.quality-title,
.schedule-block > span,
.comparison-table-heading h3 {
    color: var(--navy-dark);
    font-size: 13px;
    font-weight: 800;
}

select,
input[type="search"] {
    width: 100%;
    min-height: 39px;
    border: 1px solid #c8dce7;
    border-radius: 5px;
    padding: 0 12px;
    background: #ffffff;
    color: var(--ink);
}

select:focus,
input[type="search"]:focus,
button:focus-visible {
    outline: 2px solid rgba(23, 169, 224, 0.38);
    outline-offset: 2px;
}

.drop-zone {
    position: relative;
    display: grid;
    min-height: 254px;
    margin-top: 12px;
    place-items: center;
    border: 1px dashed #9fb9c8;
    border-radius: 4px;
    background: #fbfdff;
    text-align: center;
    overflow: hidden;
}

.drop-zone input {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.drop-zone .upload-icon {
    display: grid;
    width: 52px;
    height: 52px;
    margin-top: 18px;
    place-items: center;
    color: #6d8795;
}

.upload-icon svg {
    width: 46px;
    height: 46px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.drop-zone strong {
    display: block;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 500;
}

.drop-zone em {
    color: var(--muted);
    font-style: normal;
}

.browse-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 152px;
    min-height: 39px;
    margin-bottom: 28px;
    border: 1px solid var(--advent-deep-green);
    border-radius: 4px;
    color: var(--advent-deep-green);
    background: #ffffff;
    font-weight: 750;
}

.mapping-column {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.mapping-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-soft);
}

.mapping-heading span {
    color: var(--muted);
    font-size: 12px;
}

.mapping-list {
    display: grid;
    gap: 12px;
    padding-top: 12px;
}

.mapping-row {
    display: grid;
    grid-template-columns: 140px minmax(150px, 1fr) 24px;
    gap: 8px;
    align-items: center;
}

.mapping-row label {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mapping-status {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 900;
}

.mapping-status.auto {
    background: var(--green);
}

.mapping-status.manual {
    background: #6a7780;
}

.mapping-status.missing {
    background: var(--red);
}

.link-button {
    align-self: center;
    margin-top: 12px;
    border: 0;
    color: var(--advent-blue);
    background: transparent;
    font-weight: 750;
}

.link-button::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 7px;
    border: 2px solid currentColor;
    border-radius: 2px;
    transform: rotate(-35deg);
    vertical-align: -1px;
}

.status-banner {
    margin: 0 16px 12px;
    border-radius: 5px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.35;
}

.status-banner.warning {
    border: 1px solid #f2c56d;
    background: #fff8e6;
    color: #855600;
}

.status-banner.danger {
    border: 1px solid #f0b1aa;
    background: #fff0ef;
    color: #a21418;
}

.quality-panel {
    display: grid;
    grid-template-columns: 145px minmax(0, 1fr) 170px;
    margin: 0 16px 16px;
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow: hidden;
}

.valid-score,
.skipped-total {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    background: #ffffff;
}

.valid-score {
    border-right: 1px solid var(--line);
}

.valid-score span,
.skipped-total span {
    font-size: 12px;
    font-weight: 800;
}

.valid-score strong {
    color: var(--green);
    font-size: 28px;
    line-height: 1;
    font-weight: 500;
}

.skipped-total {
    border-left: 1px solid var(--line);
}

.skipped-total strong {
    color: var(--red);
    font-size: 29px;
    line-height: 1;
    font-weight: 500;
}

.skipped-total em {
    color: var(--red);
    font-size: 13px;
    font-style: normal;
}

.skipped-reasons {
    min-width: 0;
}

.quality-title {
    padding: 8px 12px 4px;
}

.skipped-reasons table,
.comparison-table {
    width: 100%;
    border-collapse: collapse;
}

.skipped-reasons th,
.skipped-reasons td,
.comparison-table th,
.comparison-table td {
    border-top: 1px solid var(--line-soft);
    padding: 7px 10px;
    font-size: 12px;
    white-space: nowrap;
}

.skipped-reasons th,
.comparison-table th {
    color: var(--ink);
    font-weight: 800;
    text-align: left;
}

.skipped-reasons th:nth-child(2),
.skipped-reasons th:nth-child(3),
.skipped-reasons td:nth-child(2),
.skipped-reasons td:nth-child(3) {
    text-align: right;
}

.skipped-reasons td:first-child {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reason-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 7px;
    border-radius: 999px;
    background: var(--amber);
}

.filter-strip {
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) minmax(220px, 0.7fr) minmax(220px, 0.7fr) minmax(220px, 0.7fr) 240px;
    gap: 28px;
    align-items: end;
    margin-top: 14px;
    padding: 16px 20px;
}

.schedule-block {
    display: grid;
    gap: 7px;
}

.schedule-segment {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: 1px solid #c8dce7;
    border-radius: 5px;
    overflow: hidden;
}

.schedule-segment button {
    min-height: 40px;
    border: 0;
    border-right: 1px solid #c8dce7;
    background: #ffffff;
    color: var(--ink);
    font-weight: 800;
}

.schedule-segment button:last-child {
    border-right: 0;
}

.schedule-segment button.active {
    background: var(--advent-blue);
    color: #ffffff;
}

.compare-button {
    width: 100%;
    min-height: 48px;
}

.compare-button::before {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 12px;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 12px solid currentColor;
    vertical-align: -2px;
}

.compare-summary {
    display: grid;
    grid-template-columns: 170px minmax(150px, 1.1fr) repeat(4, minmax(150px, 1fr)) minmax(220px, 1.1fr);
    align-items: stretch;
    margin-top: 12px;
    overflow: hidden;
}

.compare-title {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    border-right: 1px solid var(--line);
}

.compare-title h2 {
    color: var(--navy-dark);
    font-size: 28px;
}

.summary-metric {
    display: grid;
    align-content: center;
    gap: 4px;
    min-width: 0;
    padding: 14px 20px;
    border-right: 1px solid var(--line);
}

.summary-metric:last-child {
    border-right: 0;
}

.summary-metric span {
    font-weight: 800;
}

.summary-metric em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.summary-metric strong {
    color: var(--green);
    font-size: 28px;
    line-height: 1;
    font-weight: 500;
}

.summary-metric strong.delta-worse,
.delta-worse {
    color: var(--red);
}

.summary-metric strong.delta-better,
.delta-better {
    color: var(--green);
}

.summary-metric.rows strong {
    font-size: 24px;
}

.comparison-narrative {
    margin-top: 8px;
    padding: 10px 14px;
    color: var(--muted);
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.comparison-table-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.comparison-table-heading span {
    color: var(--muted);
    font-size: 12px;
}

.comparison-table-shell {
    height: 330px;
    overflow: auto;
}

.comparison-table {
    table-layout: fixed;
}

.comparison-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fafcfd;
    text-align: center;
}

.comparison-table thead tr:nth-child(2) th {
    top: 31px;
    z-index: 1;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
    width: 24%;
    text-align: left;
}

.comparison-table td {
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
}

.comparison-table td:first-child {
    text-align: left;
}

.empty-cell {
    color: var(--muted);
    text-align: center !important;
}

.blazor-error-boundary {
    border-radius: 6px;
    padding: 1rem;
    background: var(--red);
    color: #ffffff;
}

@media (max-width: 1120px) {
    .dataset-card-main {
        grid-template-columns: 1fr;
    }

    .drop-zone {
        min-height: 190px;
    }

    .filter-strip,
    .compare-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .compare-title,
    .summary-metric {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 980px) {
    .dashboard-shell {
        width: min(100vw - 20px, 1840px);
    }

    .app-bar,
    .dataset-grid,
    .filter-strip,
    .compare-summary,
    .comparison-grid,
    .quality-panel {
        grid-template-columns: 1fr;
    }

    .app-bar {
        align-items: stretch;
    }

    .app-actions {
        justify-content: space-between;
    }

    .brand-lockup {
        justify-content: flex-start;
    }

    .mapping-row {
        grid-template-columns: 1fr;
    }

    .mapping-status {
        display: none;
    }

    .valid-score,
    .skipped-total {
        min-height: 92px;
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .comparison-table-shell {
        height: 300px;
    }
}

@media (max-width: 520px) {
    .app-bar {
        flex-wrap: wrap;
        gap: 10px;
        padding-inline: 10px;
    }

    .brand-lockup,
    .app-actions {
        width: 100%;
    }

    .brand-logo-frame {
        width: 142px;
        height: 36px;
        padding: 4px 8px;
    }

    .brand-logo {
        max-height: 28px;
    }

    .brand-lockup h1 {
        font-size: 20px;
    }

    .app-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .bar-button,
    .compare-button {
        width: 100%;
        min-width: 0;
        padding-inline: 10px;
    }
}
