:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #1f2937;
    --muted: #667085;
    --line: #dde5f0;
    --accent: #315af2;
    --accent-2: #7c3aed;
    --accent-soft: #edf2ff;
    --success: #13a86b;
    --success-soft: #e9f8f1;
    --warning: #ef8f16;
    --warning-soft: #fff4df;
    --danger: #dc3545;
    --danger-soft: #fff0f2;
    --shadow: 0 18px 45px rgba(31, 41, 55, 0.08);
    --radius: 8px;
    --sidebar-width: 278px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(49, 90, 242, 0.08), rgba(124, 58, 237, 0.04) 34%, transparent 60%),
        var(--bg);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 28px 22px;
    color: #ffffff;
    background: linear-gradient(180deg, #1c2746 0%, #22305f 54%, #16203e 100%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 14px 28px rgba(49, 90, 242, 0.35);
    font-weight: 800;
}

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

.brand strong {
    font-size: 16px;
}

.brand small {
    color: rgba(255, 255, 255, 0.64);
    font-size: 12px;
}

.side-nav {
    display: grid;
    gap: 7px;
}

.side-nav a {
    display: block;
    padding: 11px 12px;
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.side-nav a:hover,
.side-nav a:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.11);
    transform: translateX(3px);
    outline: none;
}

.sidebar-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: auto;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.74);
    background: rgba(255, 255, 255, 0.08);
    font-size: 13px;
}

.status-dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(19, 168, 107, 0.18);
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
    padding: 26px 28px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.eyebrow,
.section-kicker {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: 28px;
    line-height: 1.22;
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
}

.topbar-actions,
.button-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.panel {
    margin-bottom: 22px;
    padding: 24px;
    border: 1px solid rgba(221, 229, 240, 0.9);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.hero-panel {
    border-top: 4px solid var(--accent);
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-info {
    color: #2442b0;
    background: var(--accent-soft);
}

.badge-success {
    color: #08764a;
    background: var(--success-soft);
}

.badge-warning {
    color: #935206;
    background: var(--warning-soft);
}

.badge-danger {
    color: #a61d2c;
    background: var(--danger-soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 800;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 12px 22px rgba(49, 90, 242, 0.22);
}

.btn-primary:hover {
    box-shadow: 0 16px 28px rgba(49, 90, 242, 0.3);
}

.btn-secondary {
    color: var(--text);
    border-color: var(--line);
    background: #ffffff;
}

.btn-secondary:hover {
    border-color: #b8c4d6;
    background: var(--panel-soft);
}

.btn-danger {
    color: var(--danger);
    border-color: rgba(220, 53, 69, 0.26);
    background: var(--danger-soft);
}

.btn-icon {
    min-width: 38px;
    min-height: 38px;
    padding: 0 11px;
}

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

.field,
.range-field {
    display: grid;
    gap: 8px;
}

.field-wide {
    grid-column: 1 / -1;
}

.field span,
.range-field span {
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cfd8e6;
    border-radius: var(--radius);
    color: var(--text);
    background: #ffffff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input,
select {
    min-height: 42px;
    padding: 9px 11px;
}

textarea {
    min-height: 104px;
    padding: 11px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(49, 90, 242, 0.12);
    outline: none;
}

input[type="number"] {
    appearance: textfield;
}

input[type="range"] {
    min-height: auto;
    padding: 0;
    accent-color: var(--accent);
}

.model-list,
.criteria-list {
    display: grid;
    gap: 12px;
}

.model-row,
.criterion-row {
    display: grid;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.model-row {
    grid-template-columns: minmax(180px, 1fr) auto;
}

.criterion-row {
    grid-template-columns: minmax(180px, 1.6fr) minmax(160px, 1fr) minmax(110px, 0.5fr) auto auto;
}

.model-row:hover,
.criterion-row:hover {
    border-color: #b8c4d6;
    box-shadow: 0 10px 24px rgba(31, 41, 55, 0.06);
}

.summary-strip,
.metric-grid,
.sensitivity-output {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.summary-strip {
    margin-bottom: 16px;
}

.summary-strip div,
.metric-card,
.control-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.summary-strip span,
.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-strip strong,
.metric-card strong {
    display: block;
    margin-top: 4px;
    font-size: 22px;
}

.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 46px;
    height: 26px;
}

.toggle input {
    position: absolute;
    opacity: 0;
}

.toggle span {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.18s ease;
}

.toggle span::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(31, 41, 55, 0.2);
    transition: transform 0.18s ease;
}

.toggle input:checked + span {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.toggle input:checked + span::after {
    transform: translateX(20px);
}

.scale-help {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.scale-help span {
    padding: 6px 9px;
    border-radius: 999px;
    color: #475467;
    background: var(--panel-soft);
    font-size: 12px;
    font-weight: 700;
}

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

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #ffffff;
}

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

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #344054;
    background: #f1f5f9;
    font-size: 13px;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: #fbfdff;
}

.score-select {
    min-width: 84px;
}

.formula {
    display: inline-flex;
    align-items: center;
    padding: 8px 11px;
    border-radius: var(--radius);
    color: #2442b0;
    background: var(--accent-soft);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    font-weight: 800;
}

.metric-grid {
    margin-bottom: 16px;
}

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

.result-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.result-card.is-leader {
    border-color: rgba(49, 90, 242, 0.34);
    box-shadow: 0 16px 30px rgba(49, 90, 242, 0.12);
}

.result-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.result-value {
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
}

.progress {
    width: 100%;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef7;
}

.progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.progress.success span {
    background: linear-gradient(90deg, #10a865, #41c986);
}

.progress.warning span {
    background: linear-gradient(90deg, #ef8f16, #f6b04d);
}

.progress.danger span {
    background: linear-gradient(90deg, #dc3545, #f56c7a);
}

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

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-flex;
    padding: 4px 7px;
    border-radius: 999px;
    color: #344054;
    background: #eef3fb;
    font-size: 12px;
    font-weight: 700;
}

.contribution-list,
.sensitivity-deltas {
    display: grid;
    gap: 10px;
}

.contribution-item,
.delta-item {
    display: grid;
    gap: 7px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.bar-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #344054;
    font-weight: 800;
}

.bar-track {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef7;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.control-card {
    display: grid;
    gap: 16px;
}

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

.metric-wide {
    grid-column: 1 / -1;
}

.report-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.report-card h3 {
    margin-bottom: 10px;
}

.report-card p {
    margin-bottom: 10px;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 20;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: var(--radius);
    color: #ffffff;
    background: #172033;
    box-shadow: 0 18px 36px rgba(23, 32, 51, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: var(--danger);
}

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

    .sidebar {
        position: static;
        height: auto;
        padding: 18px;
    }

    .side-nav {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        overflow-x: auto;
    }

    .side-nav a {
        text-align: center;
        white-space: nowrap;
    }

    .sidebar-note {
        display: none;
    }
}

@media (max-width: 900px) {
    .workspace {
        padding: 18px;
    }

    .topbar,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions,
    .button-row {
        justify-content: flex-start;
    }

    .project-grid,
    .sensitivity-grid,
    .summary-strip,
    .metric-grid,
    .result-cards {
        grid-template-columns: 1fr;
    }

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

    .sensitivity-output {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    h1 {
        font-size: 23px;
    }

    h2 {
        font-size: 19px;
    }

    .workspace {
        padding: 12px;
    }

    .panel,
    .topbar {
        padding: 18px;
    }

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

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

    .btn,
    .topbar-actions,
    .button-row {
        width: 100%;
    }

    .badge {
        width: fit-content;
    }
}
