:root {
    --navy-950: #17232e;
    --navy-900: #22303c;
    --navy-800: #2c3b48;
    --blue-600: #0788d1;
    --blue-500: #129be2;
    --blue-100: #e9f6fd;
    --slate-700: #44515d;
    --slate-600: #5e6a75;
    --slate-400: #9aa5af;
    --slate-300: #cbd3da;
    --slate-200: #e2e7eb;
    --slate-100: #f3f6f8;
    --white: #ffffff;
    --green-600: #198754;
    --green-100: #e8f6ee;
    --red-600: #b42318;
    --red-100: #fdecec;
    --amber-600: #9a6700;
    --amber-100: #fff3d6;
    --shadow-sm: 0 3px 12px rgb(15 31 45 / 7%);
    --shadow-md: 0 12px 30px rgb(15 31 45 / 10%);
    --radius-sm: 7px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--slate-100);
    color: var(--navy-950);
    font-family:
        Inter,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

a {
    color: var(--blue-600);
}

button,
input,
select {
    font: inherit;
}

/* Header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    padding: 0 36px;
    background: var(--white);
    border-bottom: 1px solid var(--slate-200);
    box-shadow: 0 1px 8px rgb(15 31 45 / 5%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--navy-950);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border: 3px solid var(--blue-600);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--blue-600);
    font-size: 14px;
    font-weight: 800;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 26px;
}

.site-header nav > a {
    color: var(--navy-900);
    font-weight: 650;
    text-decoration: none;
}

.site-header nav > a:hover {
    color: var(--blue-600);
}

.account-menu {
    padding-left: 20px;
    border-left: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    gap: 14px;
}

.account-name {
    color: var(--slate-600);
    font-size: 14px;
}

.inline-form {
    display: inline;
    margin: 0;
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--blue-600);
    cursor: pointer;
    font-weight: 650;
}

/* Main layout */

.page-container {
    width: min(1220px, calc(100% - 48px));
    margin: 38px auto 60px;
}

.hero-panel {
    position: relative;
    overflow: hidden;
    min-height: 260px;
    margin-bottom: 32px;
    padding: 48px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(
            circle at 88% 15%,
            rgb(18 155 226 / 35%),
            transparent 32%
        ),
        linear-gradient(120deg, var(--navy-950), var(--navy-800));
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.hero-panel::after {
    content: "";
    position: absolute;
    right: -100px;
    bottom: -170px;
    width: 430px;
    height: 430px;
    border: 55px solid rgb(255 255 255 / 8%);
    border-radius: 50%;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 720px;
}

.eyebrow {
    margin-bottom: 14px;
    color: #9fdcff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hero-panel h1 {
    max-width: 780px;
    margin: 0;
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    font-size: clamp(34px, 5vw, 54px);
    line-height: 1.06;
    letter-spacing: -0.025em;
}

.hero-panel p {
    max-width: 670px;
    margin: 20px 0 0;
    color: rgb(255 255 255 / 82%);
    font-size: 18px;
}

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

.page-heading h1,
.section-heading h2 {
    margin: 0;
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    color: var(--navy-950);
    letter-spacing: -0.015em;
}

.page-heading h1 {
    font-size: 34px;
}

.page-heading p,
.section-heading p {
    margin: 7px 0 0;
    color: var(--slate-600);
}

.section-heading {
    margin: 34px 0 17px;
}

/* Cards */

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.card {
    min-height: 220px;
    padding: 28px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition:
        transform 160ms ease,
        box-shadow 160ms ease,
        border-color 160ms ease;
}

.card:hover {
    transform: translateY(-3px);
    border-color: #abd9f2;
    box-shadow: var(--shadow-md);
}

.card-icon {
    width: 46px;
    height: 46px;
    margin-bottom: 20px;
    border-radius: 50%;
    background: var(--blue-100);
    color: var(--blue-600);
    display: grid;
    place-items: center;
    font-size: 21px;
    font-weight: 800;
}

.card h2 {
    margin: 0 0 9px;
    font-size: 21px;
}

.card p {
    margin: 0 0 24px;
    color: var(--slate-600);
}

.card-actions {
    margin-top: auto;
}

/* Buttons */

.primary-button,
.secondary-button,
.danger-button {
    min-height: 42px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 750;
    text-decoration: none;
    transition:
        transform 120ms ease,
        background 120ms ease,
        border-color 120ms ease;
}

.primary-button {
    background: var(--blue-600);
    color: var(--white);
}

.primary-button:hover {
    background: #0078bb;
    transform: translateY(-1px);
}

.secondary-button {
    border-color: var(--slate-300);
    background: var(--white);
    color: var(--navy-900);
}

.secondary-button:hover {
    border-color: var(--blue-600);
    color: var(--blue-600);
}

.danger-button {
    background: var(--red-600);
    color: var(--white);
}

/* Forms */

.form-card,
.upload-card,
.table-container,
.login-card {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.form-card,
.upload-card {
    padding: 30px;
}

.form-card {
    width: min(680px, 100%);
}

label {
    display: block;
    margin: 19px 0 7px;
    color: var(--navy-900);
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--navy-950);
}

input:focus,
select:focus {
    outline: 3px solid rgb(7 136 209 / 16%);
    border-color: var(--blue-600);
}

small,
.field-help {
    display: block;
    margin-top: 7px;
    color: var(--slate-600);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
}

.form-actions {
    margin-top: 26px;
    display: flex;
    gap: 11px;
}

/* Upload */

.upload-dropzone {
    padding: 42px 24px;
    border: 2px dashed #aebbc5;
    border-radius: var(--radius-md);
    background: #fafcfd;
    text-align: center;
}

.upload-dropzone h2 {
    margin: 13px 0 7px;
}

.upload-dropzone p {
    margin: 0 0 20px;
    color: var(--slate-600);
}

.upload-symbol {
    width: 60px;
    height: 60px;
    margin: 0 auto;
    border-radius: 50%;
    background: var(--blue-100);
    color: var(--blue-600);
    display: grid;
    place-items: center;
    font-size: 28px;
}

.upload-row {
    margin-top: 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
}

/* Tables */

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 17px;
    border-bottom: 1px solid var(--slate-200);
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafb;
    color: var(--slate-700);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #fbfdfe;
}

.actions {
    display: flex;
    gap: 8px;
}

/* Status and alerts */

.badge,
.status {
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    align-items: center;
    font-size: 12px;
    font-weight: 750;
}

.badge {
    margin-left: 5px;
    background: #e9eef2;
}

.status-active,
.status-completed {
    background: var(--green-100);
    color: var(--green-600);
}

.status-inactive,
.status-failed {
    background: var(--red-100);
    color: var(--red-600);
}

.status-pending,
.status-processing {
    background: var(--blue-100);
    color: var(--blue-600);
}

.status-warning {
    background: var(--amber-100);
    color: var(--amber-600);
}

.alert {
    margin-bottom: 20px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
}

.alert-error {
    border: 1px solid #efb4af;
    background: var(--red-100);
    color: var(--red-600);
}

.alert-success {
    border: 1px solid #b6dfc5;
    background: var(--green-100);
    color: var(--green-600);
}

/* Login */

.login-page {
    min-height: 100vh;
    padding: 25px;
    background:
        radial-gradient(
            circle at 82% 18%,
            rgb(18 155 226 / 32%),
            transparent 28%
        ),
        linear-gradient(135deg, var(--navy-950), var(--navy-800));
    display: grid;
    place-items: center;
}

.login-card {
    width: min(430px, 100%);
    padding: 38px;
}

.login-brand {
    margin-bottom: 30px;
    text-align: center;
}

.login-brand .brand-mark {
    margin: 0 auto 13px;
}

.login-brand h1 {
    margin: 0;
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    font-size: 34px;
}

.login-card .primary-button {
    width: 100%;
    margin-top: 24px;
}

/* Responsive */

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

    .site-header {
        padding: 15px 22px;
        align-items: flex-start;
        flex-direction: column;
        gap: 15px;
    }

    .site-header nav {
        flex-wrap: wrap;
        gap: 14px;
    }

    .account-menu {
        padding-left: 0;
        border-left: 0;
    }
}

@media (max-width: 620px) {
    .page-container {
        width: min(100% - 28px, 1220px);
        margin-top: 20px;
    }

    .hero-panel {
        min-height: auto;
        padding: 32px 25px;
    }

    .hero-panel h1 {
        font-size: 35px;
    }

    .page-heading,
    .upload-row {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .actions,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }
}

/* Processing job details */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}
.detail-grid div {
    padding: 1rem;
    border: 1px solid #dfe5ee;
    border-radius: 10px;
    background: #f8fafc;
}
.detail-grid dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #607086; }
.detail-grid dd { margin: .35rem 0 0; font-weight: 700; }

/* Processing engine */
.job-title-row { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.progress-track { width:100%; height:12px; margin:20px 0 8px; overflow:hidden; border-radius:999px; background:#e5edf5; }
.progress-fill { height:100%; border-radius:inherit; background:#0788d1; transition:width .25s ease; }
.progress-caption { margin:0 0 24px; color:#526579; }
.detail-grid dd small { display:block; margin-top:4px; color:#65788a; font-weight:400; }

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 1.25rem 0 .5rem;
}
.muted { color: #526577; font-size: .92rem; }

/* Phase 4 operator review */
.review-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:1rem;margin:1rem 0}.review-grid label{display:flex;flex-direction:column;gap:.35rem;font-weight:600}.review-grid input{width:100%;padding:.65rem;border:1px solid #cbd5e1;border-radius:.45rem}.review-required{border-left:4px solid #b91c1c}.review-row code{font-size:.85rem}button:disabled{opacity:.5;cursor:not-allowed}

/* Phase 4.1 interactive review table */
.review-summary-card{margin-bottom:1rem}.review-metrics{display:grid;grid-template-columns:repeat(4,minmax(130px,1fr));gap:1rem;margin-top:1.25rem}.review-metrics div{padding:1rem;border:1px solid var(--slate-200);border-radius:var(--radius-sm);background:#f8fafc}.review-metrics span{display:block;font-size:1.75rem;font-weight:800;color:var(--navy-900)}.review-metrics small{color:var(--slate-600)}
.review-table-card{padding:0;overflow:hidden}.review-toolbar,.review-bulkbar{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:1rem 1.25rem;border-bottom:1px solid var(--slate-200)}.review-filters{display:flex;flex-wrap:wrap;gap:.5rem}.filter-button{padding:.55rem .8rem;border:1px solid var(--slate-300);border-radius:999px;background:#fff;color:var(--slate-700);font-weight:700;cursor:pointer}.filter-button.active{border-color:var(--blue-600);background:var(--blue-100);color:var(--blue-600)}.review-search{width:min(330px,100%);margin:0}.review-bulkbar{justify-content:flex-start;background:#f8fafc}.review-bulkbar label{display:flex;align-items:center;gap:.45rem}.review-bulkbar #save-state{margin-left:auto}
.review-table-wrap{overflow:auto;max-height:68vh}.review-table{min-width:2100px;font-size:.86rem}.review-table th{position:sticky;top:0;z-index:3;white-space:nowrap}.review-table td{padding:.55rem .65rem;vertical-align:top}.review-table .sticky-col{position:sticky;z-index:2;background:inherit}.review-table th.sticky-col{z-index:5;background:#f8fafb}.review-table .select-col{left:0;width:42px;min-width:42px}.review-table .status-col{left:42px;width:125px;min-width:125px}.review-table tr{background:#fff}.review-table tr.row-needs-review{background:#fff7ed}.review-table tr.row-reviewed{background:#f0fdf4}.review-table tr.row-dirty{box-shadow:inset 4px 0 0 #0788d1}.review-table tr.row-needs-review .sticky-col{background:#fff7ed}.review-table tr.row-reviewed .sticky-col{background:#f0fdf4}.review-table tr:not(.row-needs-review):not(.row-reviewed) .sticky-col{background:#fff}
.cell-editor{min-width:145px;width:100%;padding:.5rem .55rem;border:1px solid transparent;border-radius:.35rem;background:transparent;font:inherit}.cell-editor:hover,.cell-editor:focus{border-color:var(--slate-300);background:#fff;outline:none}.issues-col,.issues-cell{min-width:260px;max-width:360px}.issues-cell summary{cursor:pointer;font-weight:700;color:var(--amber-600)}.issues-cell ul{margin:.55rem 0 0;padding-left:1.15rem}.row-status{display:inline-flex;padding:.35rem .55rem;border-radius:999px;font-weight:800;white-space:nowrap}.row-status-warning{background:var(--amber-100);color:var(--amber-600)}.row-status-reviewed{background:var(--green-100);color:var(--green-600)}.row-status-clean{background:#e9eef2;color:var(--slate-700)}.review-empty{padding:2rem;text-align:center;color:var(--slate-600)}.approval-card{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-top:1rem}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(max-width:800px){.review-metrics{grid-template-columns:repeat(2,1fr)}.review-toolbar,.approval-card{align-items:stretch;flex-direction:column}.review-search{width:100%}.review-bulkbar{flex-wrap:wrap}.review-bulkbar #save-state{width:100%;margin-left:0}}
/* Phase 5 mapping workspace */
.mapping-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1rem;margin:1rem 0}.mapping-summary>div{background:var(--panel,#fff);border:1px solid var(--border,#dce3ea);border-radius:10px;padding:1rem;display:flex;flex-direction:column}.mapping-summary strong{font-size:1.5rem}.mapping-summary span{color:#64748b}.mapping-profile-bar{display:grid;grid-template-columns:minmax(220px,1fr) auto minmax(260px,1.4fr);gap:1rem;align-items:end;margin-bottom:1rem}.mapping-table select{min-width:260px;width:100%}.mapping-table td,.mapping-table th{vertical-align:middle}.mapping-missing{background:#fff1f2}.mapping-example{max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mapping-actions{display:flex;justify-content:space-between;align-items:center;gap:1rem;margin-top:1rem}.source-preview{max-height:420px}.source-preview table{font-size:.84rem}.status-pill{display:inline-block;border-radius:999px;padding:.2rem .55rem;background:#e2e8f0;font-size:.78rem}.status-warning{background:#ffedd5;color:#9a3412}.status-success{background:#dcfce7;color:#166534}@media(max-width:900px){.mapping-summary{grid-template-columns:repeat(2,1fr)}.mapping-profile-bar{grid-template-columns:1fr}.mapping-actions{align-items:stretch;flex-direction:column}.mapping-table select{min-width:200px}}

/* Phase 5.1 compact review table and duplicate grouping */
.review-table{min-width:1680px;font-size:.74rem;line-height:1.18}
.review-table td{padding:.28rem .34rem}
.review-table th{padding:.42rem .36rem;font-size:.72rem}
.cell-editor{min-width:108px;padding:.3rem .36rem;font-size:.74rem}
.review-table .status-col{width:104px;min-width:104px}
.review-table .select-col{width:34px;min-width:34px}
.review-table .status-col{left:34px}
.issues-col,.issues-cell{min-width:220px;max-width:300px}
.row-actions{min-width:122px}.row-actions .secondary-button{display:block;width:100%;padding:.38rem .46rem;margin:0 0 .3rem;font-size:.7rem}
.duplicate-group-label{display:inline-block;margin-bottom:.18rem;padding:.18rem .36rem;border-radius:.3rem;background:rgba(15,23,42,.1)}
.duplicate-reason{font-weight:700;margin-bottom:.35rem}
.review-table tr.row-duplicate.duplicate-shade-0{background:#fff1f2}.review-table tr.row-duplicate.duplicate-shade-1{background:#fffbeb}.review-table tr.row-duplicate.duplicate-shade-2{background:#f0fdf4}.review-table tr.row-duplicate.duplicate-shade-3{background:#eff6ff}.review-table tr.row-duplicate.duplicate-shade-4{background:#faf5ff}.review-table tr.row-duplicate.duplicate-shade-5{background:#f0fdfa}
.review-table tr.row-duplicate.duplicate-shade-0 .sticky-col{background:#fff1f2}.review-table tr.row-duplicate.duplicate-shade-1 .sticky-col{background:#fffbeb}.review-table tr.row-duplicate.duplicate-shade-2 .sticky-col{background:#f0fdf4}.review-table tr.row-duplicate.duplicate-shade-3 .sticky-col{background:#eff6ff}.review-table tr.row-duplicate.duplicate-shade-4 .sticky-col{background:#faf5ff}.review-table tr.row-duplicate.duplicate-shade-5 .sticky-col{background:#f0fdfa}
.review-table tr.row-duplicate-rejected{opacity:.78}.row-status-duplicate{background:#fee2e2;color:#b91c1c}.row-status-rejected{background:#e2e8f0;color:#475569}

/* Phase 5.2 review corrections */
.review-table .sticky-right{position:sticky;right:0;z-index:4;background:inherit;box-shadow:-1px 0 0 var(--slate-200)}
.review-table th.sticky-right{z-index:6;background:#f8fafb}
.review-table tr.row-needs-review .sticky-right{background:#fff7ed}
.review-table tr.row-reviewed .sticky-right{background:#f0fdf4}
.review-table tr.row-duplicate.duplicate-shade-0 .sticky-right{background:#fff1f2}
.review-table tr.row-duplicate.duplicate-shade-1 .sticky-right{background:#fffbeb}
.review-table tr.row-duplicate.duplicate-shade-2 .sticky-right{background:#f0fdf4}
.review-table tr.row-duplicate.duplicate-shade-3 .sticky-right{background:#eff6ff}
.review-table tr.row-duplicate.duplicate-shade-4 .sticky-right{background:#faf5ff}
.review-table tr.row-duplicate.duplicate-shade-5 .sticky-right{background:#f0fdfa}
.actions-col,.row-actions{width:132px;min-width:132px}

/* Phase 5.4 compact column bulk controls */
.review-table th .set-all-column {
  display: block;
  margin-top: 3px;
  padding: 2px 5px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #334155;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
}
.review-table th .set-all-column:hover { background: #f1f5f9; }
