:root {
    --bg: #f5efe5;
    --bg-accent: #f0c987;
    --panel: rgba(255, 252, 246, 0.86);
    --panel-strong: #fffaf1;
    --ink: #1c2b2d;
    --muted: #5f6c6d;
    --line: rgba(28, 43, 45, 0.12);
    --accent: #0f766e;
    --accent-dark: #0a4f4a;
    --accent-hot: #d97706;
    --matched: #1f8f6b;
    --review: #e29d1d;
    --missing: #cb5a4d;
    --shadow: 0 24px 80px rgba(34, 49, 63, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(217, 119, 6, 0.18), transparent 30%),
        radial-gradient(circle at right 10% top 15%, rgba(15, 118, 110, 0.18), transparent 28%),
        linear-gradient(180deg, #f8f2ea 0%, #f4ecdf 48%, #f7f3ec 100%);
    color: var(--ink);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.background-glow {
    position: fixed;
    width: 28rem;
    height: 28rem;
    border-radius: 999px;
    filter: blur(70px);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
}

.background-glow-left {
    top: -8rem;
    left: -8rem;
    background: rgba(217, 119, 6, 0.3);
}

.background-glow-right {
    right: -8rem;
    top: 14rem;
    background: rgba(15, 118, 110, 0.24);
}

.analysis-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(18, 29, 31, 0.48);
    backdrop-filter: blur(10px);
}

.analysis-overlay[hidden] {
    display: none;
}

.analysis-overlay-card {
    width: min(30rem, calc(100vw - 2rem));
    padding: 1.6rem;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: linear-gradient(180deg, rgba(255, 252, 246, 0.98), rgba(250, 244, 233, 0.96));
    box-shadow: 0 32px 90px rgba(19, 29, 32, 0.24);
    text-align: center;
}

.analysis-pending {
    cursor: progress;
}

.analysis-pending .button,
.analysis-pending input,
.analysis-pending a {
    pointer-events: none;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1380px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    animation: rise 320ms ease-out;
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.9fr);
    gap: 1.5rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
    background:
        linear-gradient(135deg, rgba(255, 250, 241, 0.96), rgba(254, 244, 224, 0.9)),
        var(--panel);
}

.hero-card h1,
.section-head h2,
.empty-state h2 {
    margin: 0;
    font-family: "Avenir Next Condensed", "Arial Narrow", sans-serif;
    font-size: clamp(2rem, 2.3vw, 3rem);
    line-height: 0.98;
    letter-spacing: 0.02em;
}

.hero-text,
.muted,
.meta-line,
.stacked-text span,
.stacked-text small {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 0.75rem;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.status-stack {
    display: grid;
    gap: 0.85rem;
    align-content: start;
}

.status-chip {
    padding: 1rem 1.1rem;
    border-radius: 20px;
    border: 1px solid rgba(28, 43, 45, 0.08);
    background: rgba(255, 255, 255, 0.55);
}

.status-chip span,
.stat-label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
}

.status-chip strong,
.stat-value {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.15rem;
}

.status-chip-ready {
    border-color: rgba(31, 143, 107, 0.18);
    background: rgba(31, 143, 107, 0.08);
}

.status-chip-strong {
    border-color: rgba(15, 118, 110, 0.18);
    background: rgba(15, 118, 110, 0.1);
}

.status-chip-pending {
    border-color: rgba(217, 119, 6, 0.18);
    background: rgba(217, 119, 6, 0.08);
}

.stats-grid,
.upload-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

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

.stat-card,
.upload-card,
.report-card,
.empty-state {
    padding: 1.4rem;
}

.stat-value {
    font-size: 2rem;
    font-family: "Avenir Next Condensed", "Arial Narrow", sans-serif;
}

.stat-value-small {
    font-size: 1.6rem;
}

.section-head,
.report-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.upload-form {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.upload-form label {
    font-weight: 600;
}

input[type="file"] {
    width: 100%;
    padding: 0.85rem;
    border: 1px dashed rgba(15, 118, 110, 0.35);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
}

input[type="file"]::file-selector-button {
    margin-right: 1rem;
    padding: 0.65rem 0.95rem;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--accent-dark);
    font-weight: 700;
    cursor: pointer;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.2rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(15, 118, 110, 0.22);
}

.button-secondary {
    background: linear-gradient(135deg, #d97706, #b45309);
}

.button-ghost {
    margin-top: 0.85rem;
    background: transparent;
    border: 1px solid rgba(15, 118, 110, 0.24);
    color: var(--accent-dark);
}

.button-compact {
    margin-top: 0.9rem;
    padding: 0.6rem 0.95rem;
    font-size: 0.9rem;
}

.button-review {
    background: linear-gradient(135deg, #e29d1d, #b56a04);
}

.button-osv-export {
    margin-top: 0.85rem;
    background: linear-gradient(135deg, #0f766e, #0b4d49);
}

.button-confirm {
    background: linear-gradient(135deg, #1f8f6b, #126b56);
}

.button-unconfirm {
    background: linear-gradient(135deg, #8d5e16, #6f4308);
}

.button-reject {
    background: linear-gradient(135deg, #cb5a4d, #a3392d);
}

.button-close {
    background: rgba(28, 43, 45, 0.08);
    color: var(--ink);
    box-shadow: none;
}

.utility-card {
    background:
        linear-gradient(180deg, rgba(255, 252, 246, 0.96), rgba(255, 246, 229, 0.9)),
        var(--panel);
}

.utility-note {
    margin: 0.95rem 0 0;
}

.candidate-cell {
    display: grid;
    gap: 0.8rem;
}

.review-dialog {
    width: min(1120px, calc(100vw - 2rem));
    border: 0;
    padding: 0;
    background: transparent;
}

.review-dialog::backdrop {
    background: rgba(18, 29, 31, 0.55);
    backdrop-filter: blur(8px);
}

.review-dialog-shell {
    border-radius: 28px;
    border: 1px solid rgba(28, 43, 45, 0.12);
    background:
        linear-gradient(180deg, rgba(255, 250, 242, 0.98), rgba(250, 244, 233, 0.96));
    box-shadow: 0 32px 90px rgba(19, 29, 32, 0.24);
    padding: 1.4rem;
}

.review-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.review-dialog-head h3,
.review-panel h4 {
    margin: 0;
    font-family: "Avenir Next Condensed", "Arial Narrow", sans-serif;
    font-size: 1.7rem;
    line-height: 1;
}

.review-meta-grid,
.review-compare-grid,
.review-kv-list {
    display: grid;
    gap: 1rem;
}

.review-action-row,
.report-side-panel,
.filter-row,
.status-badge-stack {
    display: flex;
    gap: 0.75rem;
}

.report-side-panel,
.status-badge-stack {
    flex-direction: column;
}

.review-meta-grid {
    grid-template-columns: 240px minmax(0, 1fr);
    margin-bottom: 1rem;
}

.review-action-row {
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.review-action-row-inline {
    margin-bottom: 0;
    justify-content: flex-start;
}

.review-action-form {
    margin: 0;
}

.review-meta-card,
.review-panel,
.review-text-card,
.review-kv-item {
    border-radius: 22px;
    border: 1px solid rgba(28, 43, 45, 0.1);
    background: rgba(255, 255, 255, 0.7);
}

.review-meta-card {
    padding: 1rem 1.1rem;
}

.review-meta-card span,
.review-kv-item span,
.review-text-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.review-meta-card strong,
.review-kv-item strong {
    display: block;
    line-height: 1.35;
}

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

.review-compare-grid-osv {
    align-items: start;
}

.review-panel {
    padding: 1.1rem;
}

.review-panel-registry {
    background: linear-gradient(180deg, rgba(255, 250, 242, 0.98), rgba(255, 246, 229, 0.98));
}

.review-panel-osv {
    background: linear-gradient(180deg, rgba(241, 250, 248, 0.98), rgba(233, 246, 243, 0.98));
}

.review-panel-registry-candidates {
    background: linear-gradient(180deg, rgba(255, 252, 246, 0.96), rgba(252, 248, 239, 0.96));
}

.review-panel-osv-sticky {
    position: sticky;
    top: 0;
}

.review-kv-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 1rem 0;
}

.review-kv-list-candidates {
    margin-bottom: 0.8rem;
}

.review-kv-item,
.review-text-card {
    padding: 0.9rem 1rem;
}

.review-text-card p {
    margin: 0 0 0.8rem;
    line-height: 1.55;
}

.review-text-card p:last-child {
    margin-bottom: 0;
}

.candidate-compare-list {
    display: grid;
    gap: 1rem;
}

.candidate-compare-card {
    border: 1px solid rgba(28, 43, 45, 0.1);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.78);
    padding: 1rem;
}

.candidate-compare-card-primary {
    border-color: rgba(15, 118, 110, 0.22);
    box-shadow: 0 14px 34px rgba(15, 118, 110, 0.08);
}

.candidate-compare-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.8rem;
}

.candidate-badges {
    align-items: flex-end;
}

.meta-line {
    margin: 1rem 0 0;
    font-size: 0.92rem;
}

.legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-row {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.candidate-count {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 700;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(28, 43, 45, 0.1);
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}

.filter-chip span {
    color: var(--muted);
    font-size: 0.84rem;
}

.filter-chip strong {
    font-size: 0.88rem;
}

.filter-chip-active {
    border-color: rgba(15, 118, 110, 0.22);
    background: rgba(15, 118, 110, 0.1);
    box-shadow: 0 12px 28px rgba(15, 118, 110, 0.1);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-matched {
    background: rgba(31, 143, 107, 0.12);
    color: var(--matched);
}

.badge-review {
    background: rgba(226, 157, 29, 0.14);
    color: #a16600;
}

.badge-missing {
    background: rgba(203, 90, 77, 0.12);
    color: var(--missing);
}

.badge-manual {
    background: rgba(15, 118, 110, 0.12);
    color: var(--accent-dark);
}

.badge-rejected {
    background: rgba(28, 43, 45, 0.12);
    color: var(--ink);
}

.badge-current {
    background: rgba(28, 43, 45, 0.1);
    color: var(--ink);
}

.table-wrap {
    overflow-x: auto;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1040px;
}

.report-table th,
.report-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(28, 43, 45, 0.08);
    vertical-align: top;
    text-align: left;
}

.report-table th {
    position: sticky;
    top: 0;
    background: rgba(245, 239, 229, 0.98);
    font-size: 0.83rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stacked-text {
    display: grid;
    gap: 0.25rem;
}

.stacked-text strong {
    line-height: 1.2;
}

.stacked-text small {
    font-size: 0.82rem;
}

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

.messages {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.message {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 12px 40px rgba(34, 49, 63, 0.08);
}

.message-success {
    border-color: rgba(31, 143, 107, 0.18);
}

.message-error {
    border-color: rgba(203, 90, 77, 0.18);
}

.empty-state {
    text-align: center;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .upload-grid,
    .hero-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 1rem, 1380px);
        padding-top: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-card,
    .stat-card,
    .upload-card,
    .report-card,
    .empty-state {
        padding: 1rem;
    }

    .hero-card h1,
    .section-head h2,
    .empty-state h2 {
        font-size: 1.8rem;
    }

    .section-head,
    .report-head {
        flex-direction: column;
    }

    .report-side-panel,
    .filter-row,
    .review-action-row {
        width: 100%;
        justify-content: flex-start;
    }

    .button,
    .button-ghost {
        width: 100%;
    }

    .review-dialog {
        width: calc(100vw - 1rem);
    }

    .review-meta-grid,
    .review-compare-grid,
    .review-kv-list {
        grid-template-columns: 1fr;
    }

    .review-dialog-head {
        flex-direction: column;
    }

    .candidate-compare-head,
    .candidate-badges,
    .review-action-row,
    .review-action-row-inline {
        flex-direction: column;
        align-items: stretch;
    }
}