/* Layout */

.wrap--wide {
    max-width: 960px;
}

.calc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.calc .card {
    margin-bottom: 0;
}

/* Form */

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0 0 18px;
    padding: 0;
    border: none;
    min-width: 0;
}

.field[hidden] {
    display: none;
}

.field label,
.field legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    padding: 0;
    margin-bottom: 7px;
}

.field label {
    margin-bottom: 0;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field input[type="number"],
.field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #fbfdfd;
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 16px; /* 16px stops iOS zooming on focus */
    transition: border-color .15s, box-shadow .15s;
}

.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6b74' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 144, 115, 0.15);
}

.field input.is-invalid {
    border-color: var(--color-danger);
}

/* Segmented radio */

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.segmented label {
    position: relative;
    cursor: pointer;
}

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

.segmented span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 11px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: var(--color-muted);
    background: #fbfdfd;
    transition: all .15s;
}

.segmented input:checked + span {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.segmented input:focus-visible + span {
    box-shadow: 0 0 0 3px rgba(15, 144, 115, 0.25);
}

.calc__form .status {
    margin: 0 0 4px;
}

.btn--ghost {
    background: transparent;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    margin-top: 4px;
}

.btn--ghost:not(:disabled):hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* Result */

.calc__result {
    position: sticky;
    top: 20px;
}

.calc__result h2 {
    font-family: var(--font-display);
    font-size: 18px;
    margin: 0 0 14px;
}

.breakdown {
    margin: 0;
}

.breakdown > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px dashed var(--color-border);
    font-size: 14px;
}

.breakdown dt {
    color: var(--color-muted);
}

.breakdown dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    word-break: break-word;
}

.breakdown__sub dt,
.breakdown__sub dd {
    color: var(--color-text);
    font-weight: 700;
}

.breakdown__minus dd {
    color: var(--color-danger);
}

.final {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--color-navy);
    color: #fff;
}

.final span {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
}

.final strong {
    font-family: var(--font-display);
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    word-break: break-word;
}

.final.is-negative strong {
    color: #ff9b8f;
}

.formula {
    margin: 14px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--color-muted);
}

.footer a {
    color: var(--color-primary-dark);
    font-weight: 600;
    text-decoration: none;
}

/* Responsive */

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

    .calc__result {
        position: static;
    }
}

@media (max-width: 480px) {
    .field-row,
    .segmented {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .segmented {
        gap: 8px;
    }

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

    .final strong {
        font-size: 24px;
        text-align: left;
    }
}
