:root {
    --bg: #e6ebef;
    --surface: #f7f9fa;
    --surface-soft: #eef2f5;
    --surface-code: #f4f7f9;
    --surface-screw: #f1f4f6;
    --surface-action: #f2f7fb;
    --surface-result: #f5f8fb;
    --ink: #20272e;
    --muted: #697986;
    --line: #c9d3db;
    --line-soft: #d9e1e7;
    --silver: #d0d8df;
    --silver-strong: #aebbc5;
    --graphite: #27313a;
    --steel: #506170;
    --steel-strong: #2f4354;
    --steel-blue: #3f6f93;
    --steel-blue-strong: #274e6d;
    --steel-line: #b9c8d3;
    --steel-warm: #b9ad91;
    --green: #237a55;
    --red: #a63d34;
    --amber: #b87512;
    --shadow: 0 14px 34px rgba(38, 49, 59, 0.11);
    --shadow-soft: 0 8px 22px rgba(38, 49, 59, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    line-height: 1.45;
}

button,
input,
select {
    font: inherit;
}

.pullout-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 18px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 74px;
    padding: 14px 18px;
    color: var(--graphite);
    background: linear-gradient(180deg, #edf1f4 0%, #c9d2d9 100%);
    border: 1px solid var(--silver-strong);
    border-bottom: 4px solid var(--steel-blue);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 24px rgba(38, 49, 59, 0.12);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--steel-blue-strong);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(1.65rem, 3vw, 2.35rem);
}

h2 {
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.back-link,
.report-actions button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    color: #fff;
    background: var(--graphite);
    border: 1px solid var(--graphite);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 800;
}

.report-actions button {
    background: var(--steel-blue);
    border-color: var(--steel-blue);
    cursor: pointer;
}

.notice-bar,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.notice-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding: 14px 16px;
    color: var(--graphite);
}

.notice-bar span {
    color: var(--muted);
}

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

.panel {
    position: relative;
    overflow: hidden;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--silver-strong);
}

.calculator-grid > .panel:nth-of-type(1) {
    background: linear-gradient(180deg, var(--surface-code), #fbfcfd);
    border-color: var(--line-soft);
}

.calculator-grid > .panel:nth-of-type(1)::before { background: var(--steel-blue); }

.calculator-grid > .panel:nth-of-type(2) {
    background: linear-gradient(180deg, var(--surface-screw), #f9fafb);
    border-color: var(--steel-line);
}

.calculator-grid > .panel:nth-of-type(2)::before { background: var(--steel-strong); }

.calculator-grid > .panel:nth-of-type(3) {
    background: linear-gradient(180deg, var(--surface-action), #f8fbfd);
    border-color: #bdccd7;
}

.calculator-grid > .panel:nth-of-type(3)::before { background: var(--steel-blue-strong); }

.calculator-grid > .panel:nth-of-type(4) {
    background: linear-gradient(180deg, var(--surface-result), #f4f7fa);
    border-color: #aebfca;
    box-shadow: var(--shadow);
}

.calculator-grid > .panel:nth-of-type(4)::before { background: var(--graphite); }

.calculator-grid > .panel:nth-of-type(5),
.calculator-grid > .panel:nth-of-type(6) {
    background: #fbfcfd;
    border-color: var(--line-soft);
    box-shadow: 0 5px 16px rgba(38, 49, 59, 0.06);
}

.calculator-grid > .panel:nth-of-type(5)::before { background: var(--steel-warm); }
.calculator-grid > .panel:nth-of-type(6)::before { background: var(--silver-strong); }

.panel > * {
    position: relative;
    z-index: 1;
}

.result-panel,
.notes-panel,
.report-panel {
    grid-column: span 2;
}

.section-title {
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(201, 211, 219, 0.72);
}

.calculator-grid > .panel:nth-of-type(1) .section-title { border-bottom-color: #cfdbe4; }
.calculator-grid > .panel:nth-of-type(2) .section-title { border-bottom-color: var(--steel-line); }
.calculator-grid > .panel:nth-of-type(3) .section-title { border-bottom-color: #bdccd7; }
.calculator-grid > .panel:nth-of-type(4) .section-title { border-bottom-color: #aebfca; }

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

.segmented label {
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    min-height: 46px;
    display: grid;
    place-items: center;
    padding: 10px;
    color: var(--graphite);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-weight: 900;
}

.segmented input:checked + span {
    color: #fff;
    background: var(--graphite);
    border-color: var(--graphite);
}

.basis-box,
.help-note,
.message-box,
.general-warning {
    margin-top: 14px;
    padding: 13px;
    border-radius: 8px;
}

.basis-box,
.help-note,
.message-box,
.general-warning,
.notes-list {
    font-size: 0.84rem;
}

.basis-box,
.help-note {
    color: var(--muted);
    background: rgba(238, 242, 245, 0.66);
    border: 1px solid var(--line-soft);
}

.calculator-grid > .panel:nth-of-type(1) .basis-box {
    background: rgba(236, 242, 247, 0.72);
    border-color: #cfdbe4;
}

.calculator-grid > .panel:nth-of-type(2) .help-note {
    background: rgba(232, 238, 242, 0.74);
    border-color: var(--steel-line);
}

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

label {
    display: block;
    color: var(--muted);
    font-size: 0;
    font-weight: 750;
    line-height: 1.25;
}

label sub {
    line-height: 0;
}

.field-label {
    display: block;
    min-height: 1.25em;
    font-size: 0.86rem;
    white-space: nowrap;
}

.unit {
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

label input,
label select {
    margin-top: 7px;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.is-hidden {
    display: none;
}

.pitch-fields-hidden .pitch-field,
.pitch-fields-hidden .help-note {
    display: none;
}

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

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    border-bottom: 1px solid var(--line-soft);
}

.result-row span {
    color: var(--muted);
    font-weight: 800;
}

.result-row strong {
    text-align: right;
}

.result-row:nth-child(3),
.result-row:nth-child(6),
.result-row:nth-child(7) {
    background: rgba(227, 237, 244, 0.44);
    margin: 0 -8px;
    padding: 0 8px;
}

.result-row:nth-last-child(-n + 3) strong {
    font-size: 1.05rem;
}

.status-pass {
    color: var(--green);
}

.status-fail,
.status-invalid {
    color: var(--red);
}

.status-note {
    color: var(--amber);
}

.message-box {
    color: #684208;
    background: #fff7e9;
    border: 1px solid #efd4aa;
}

.notes-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.42;
    columns: 2;
    column-gap: 34px;
}

.notes-list li {
    margin: 5px 0;
}

.general-warning {
    color: #684208;
    background: #fff7e9;
    border: 1px solid #efd4aa;
}

.report-preview {
    max-width: 860px;
    margin: 0 auto;
    padding: 18px 22px;
    background: #fbfcfd;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.report-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.report-actions button {
    min-height: 42px;
    padding: 9px 14px;
    color: #fff;
    background: var(--steel-blue);
    border: 1px solid var(--steel-blue);
    border-radius: 6px;
    font-weight: 900;
    cursor: pointer;
}

.report-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--steel-blue);
}

@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    body {
        background: #fff;
        font-size: 10pt;
    }

    .topbar,
    .notice-bar,
    .calculator-grid > .panel:not(.report-panel),
    .report-actions,
    .report-panel > .section-title {
        display: none !important;
    }

    .pullout-shell {
        width: 100%;
        padding: 0;
    }

    .calculator-grid {
        display: block;
        margin: 0;
    }

    .report-panel,
    .report-preview {
        box-shadow: none;
    }

    .report-panel {
        padding: 0;
    }

    .report-preview {
        width: 100%;
        max-width: 175mm;
        margin: 0 auto;
        padding: 14mm 12mm;
        background: #fbfcfd;
        border: 1px solid #c9d3db;
        border-radius: 6px;
    }

    .report-head {
        padding-bottom: 8px;
        border-bottom-width: 2px;
    }

    .report-brand {
        margin-bottom: 0;
        font-size: 8pt;
    }

    .report-head h3 {
        font-size: 15pt;
    }

    .report-status {
        min-height: 24px;
        padding: 3px 8px;
        font-size: 8pt;
    }

    .report-section {
        margin-top: 10px;
    }

    .report-section h4 {
        margin-bottom: 3px;
        font-size: 8pt;
    }

    .report-table div {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(110px, 0.6fr);
        gap: 10px;
        padding: 5px 0;
    }

    .report-note,
    .report-warning {
        margin-top: 9px;
        padding-top: 7px;
        font-size: 9pt;
    }

    .is-hidden,
    #report-pitch-row.is-hidden {
        display: none !important;
    }
}

.report-brand {
    margin-bottom: 2px;
    color: var(--steel-blue-strong);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.report-head h3 {
    margin: 0;
    font-size: 1.35rem;
}

.report-status {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    color: #fff;
    background: var(--graphite);
    border-radius: 6px;
    font-weight: 900;
}

.report-status.pass {
    background: var(--green);
}

.report-status.fail,
.report-status.invalid {
    background: var(--red);
}

.report-section {
    margin-top: 14px;
}

.report-section h4 {
    margin: 0 0 6px;
    color: var(--graphite);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.report-table {
    border-top: 1px solid var(--line);
}

.report-table div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 0.7fr);
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
}

.report-table span {
    color: var(--muted);
    font-weight: 800;
}

.report-table strong {
    text-align: right;
}

.report-note,
.report-warning {
    margin-top: 12px;
    padding: 9px 0 0;
    border-radius: 0;
}

.report-note {
    color: var(--muted);
    background: transparent;
    border-top: 1px solid var(--line);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
}

.report-warning {
    color: #684208;
    background: transparent;
    border-top: 1px solid #efd4aa;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
}

@media (max-width: 820px) {
    .calculator-grid,
    .field-grid,
    .result-card,
    .report-table div {
        grid-template-columns: 1fr;
    }

    .result-panel,
    .notes-panel,
    .report-panel {
        grid-column: span 1;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .notes-list {
        columns: 1;
    }
}
