:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-alt: #edf2f8;
    --ink: #172033;
    --muted: #657188;
    --primary: #153e75;
    --primary-soft: #e6eef8;
    --accent: #10a37f;
    --accent-soft: #e3f5f0;
    --border: #dde5ee;
    --error: #bb2d3b;
    --error-soft: #fdecef;
    --shadow: 0 12px 32px rgba(20, 38, 67, .07);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}
.navbar {
    height: 72px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(calc((100% - 1120px) / 2), 30px);
}
.brand {
    font-weight: 800;
    letter-spacing: .07em;
    color: var(--primary);
    text-decoration: none;
}
.nav-links { display: flex; gap: 28px; }
.nav-links a {
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
}
.nav-links a:hover, .text-link:hover { color: var(--primary); }
.page {
    width: min(1120px, calc(100% - 48px));
    margin: 0 auto;
    padding: 58px 0 78px;
}
h1 {
    margin: 10px 0 18px;
    font-size: clamp(2.3rem, 5vw, 3.75rem);
    letter-spacing: -.05em;
    line-height: 1.05;
}
h2 { margin: 0 0 10px; font-size: 1.25rem; }
h3 { margin: 22px 0 10px; font-size: 1rem; }
p { color: var(--muted); line-height: 1.65; margin: 0 0 18px; }
.eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .16em;
    margin: 0;
}
.hero {
    border-radius: 27px;
    padding: clamp(38px, 8vw, 82px);
    background:
        radial-gradient(circle at 83% 28%, rgba(16,163,127,.13), transparent 32%),
        linear-gradient(135deg, #fff, #eef4fb);
    border: 1px solid var(--border);
}
.hero h1 span { color: var(--primary); }
.lead {
    font-size: 1.12rem;
    line-height: 1.7;
    max-width: 720px;
}
.button-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.button {
    display: inline-flex;
    min-height: 46px;
    padding: 0 22px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}
.button:hover { transform: translateY(-1px); }
.primary {
    color: white;
    background: var(--primary);
    box-shadow: 0 8px 18px rgba(21,62,117,.18);
}
.secondary {
    color: var(--primary);
    background: var(--surface);
    border-color: var(--border);
}
.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin: 26px 0;
}
.steps article, .paper, .output-card, .form-section, .random-card, .explanation-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 17px;
    padding: 25px;
}
.step-number {
    width: 34px;
    height: 34px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    margin-bottom: 20px;
}
.paper { margin-top: 24px; }
.text-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.page-heading { margin-bottom: 34px; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.random-card {
    display: flex;
    gap: 30px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--primary-soft);
    border-color: #ccdcee;
}
.random-form {
    display: flex;
    align-items: end;
    gap: 10px;
}
label {
    color: var(--muted);
    font-size: .83rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
label small { font-weight: 400; }
input {
    height: 45px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 13px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}
input:focus {
    outline: 2px solid rgba(21,62,117,.18);
    border-color: var(--primary);
}
.random-form input { width: 104px; }
.instance-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.budget-section input { width: min(260px, 100%); }
.section-header {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}
.section-header p { margin: 0; }
.small-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    white-space: nowrap;
    padding: 10px 14px;
    font-weight: 600;
    border-radius: 9px;
    cursor: pointer;
}
.table-labels {
    display: grid;
    gap: 10px;
    color: var(--muted);
    font-weight: 600;
    font-size: .82rem;
    margin-bottom: 7px;
}
.projects-labels, .project-row { grid-template-columns: minmax(180px, 1fr) 160px 38px; }
.voters-labels, .voter-row { grid-template-columns: minmax(140px, .55fr) minmax(250px, 1.4fr) 38px; }
.input-row {
    display: grid;
    gap: 10px;
    margin: 8px 0;
}
.remove {
    border: 0;
    background: transparent;
    color: #9aa6ba;
    font-size: 1.55rem;
    cursor: pointer;
}
.remove:hover { color: var(--error); }
.run-button {
    align-self: flex-start;
    margin-top: 8px;
}
.alert {
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 22px;
    line-height: 1.45;
}
.alert.error {
    color: var(--error);
    background: var(--error-soft);
    border: 1px solid #f4c2c9;
}
.results-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
}
.results-heading .button-row { margin: 0; }
.result-grid {
    display: grid;
    grid-template-columns: 1.3fr repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.metric {
    padding: 21px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.metric span, .metric small { color: var(--muted); font-size: .84rem; }
.metric strong { font-size: 1.55rem; }
.metric.featured { background: var(--primary); color: white; }
.metric.featured span, .metric.featured small { color: #cfdbeb; }
.metric.success strong { color: var(--accent); }
.output-card { margin-bottom: 18px; }
.output-card.selected { background: linear-gradient(110deg, #fff, #f2fbf8); }
.project-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}
.pill {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--accent-soft);
    border-radius: 9px;
    padding: 12px 15px;
}
.pill span { color: #397565; font-size: .86rem; }
.subtle { font-size: .92rem; }
.responsive-table { overflow-x: auto; margin-top: 22px; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}
.status {
    padding: 5px 10px;
    border-radius: 40px;
    font-size: .8rem;
    font-weight: 600;
}
.status.chosen { background: var(--accent-soft); color: #087256; }
.status.skipped { background: var(--surface-alt); color: var(--muted); }
.two-column, .about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.clean-list, .utility-list {
    padding: 0;
    margin: 0;
    list-style: none;
}
.clean-list li, .utility-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.clean-list span { color: var(--muted); }
.utility-list small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}
.utility-list > li > span {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}
.explanation-card { background: var(--primary-soft); }
.explanation-card p { margin: 0; }
.notice {
    border: 1px solid #f0d9ae;
    background: #fff8eb;
    color: #785b21;
    border-radius: 11px;
    margin: 0 0 18px;
    padding: 15px 18px;
}
.log-heading .button { margin-top: 10px; }
.log-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 13px;
    margin: 25px 0 18px;
}
.log-summary div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 17px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.log-summary span { color: var(--muted); font-size: .82rem; }
.log-summary strong { font-size: 1.4rem; }
.terminal {
    background: #142034;
    border-radius: 15px;
    overflow: hidden;
    color: #e3eaf4;
    box-shadow: var(--shadow);
}
.terminal-bar {
    padding: 14px 18px;
    background: #202e45;
    color: #a6b4c9;
    font-size: .84rem;
}
.terminal-bar span {
    display: inline-block;
    height: 11px;
    width: 11px;
    background: #738299;
    border-radius: 100%;
    margin-right: 7px;
}
.log-lines {
    padding: 22px 22px 22px 60px;
    margin: 0;
    color: #90a7c7;
    font: .87rem/1.8 "Cascadia Code", Consolas, monospace;
}
.log-lines li::marker { color: #556984; }
.log-lines li { padding-left: 12px; color: #d8e2f0; }
.about-hero { margin-bottom: 32px; max-width: 800px; }
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    list-style: none;
    padding: 10px 0 0;
}
.tag-list li {
    background: var(--primary-soft);
    color: var(--primary);
    padding: 9px 13px;
    border-radius: 8px;
    font-weight: 600;
}
footer {
    text-align: center;
    color: var(--muted);
    font-size: .86rem;
    padding: 28px;
    border-top: 1px solid var(--border);
}
@media (max-width: 850px) {
    .steps, .result-grid, .two-column, .about-grid, .log-summary { grid-template-columns: 1fr; }
    .random-card, .random-form, .results-heading { flex-direction: column; align-items: stretch; }
    .random-form input { width: 100%; }
}
@media (max-width: 600px) {
    .page { width: calc(100% - 30px); padding-top: 36px; }
    .navbar { padding: 0 16px; }
    .nav-links { gap: 13px; }
    .projects-labels, .voters-labels { display: none; }
    .project-row, .voter-row { grid-template-columns: 1fr 38px; }
    .project-row input:first-child, .voter-row input:first-child { grid-column: 1; }
    .project-row input:nth-child(2), .voter-row input:nth-child(2) { grid-column: 1; }
    .remove { grid-column: 2; grid-row: 1 / 3; }
}
