.hbpmec,
.hbpmec * {
    box-sizing: border-box;
}

.hbpmec {
    --hbpmec-space: 1.25rem;
    --hbpmec-control-height: 42px;
    --hbpmec-focus: #1d4ed8;
    --hbpmec-border: #d9d9d9;
    --hbpmec-muted: #666;
    --hbpmec-surface: #fff;
    --hbpmec-result-surface: #f7f8fa;
    --hbpmec-accent: #4865b2;
    --hbpmec-accent-hover: #3c7fff;
    --hbpmec-slider-thumb-width: 14px;
    width: 100%;
    max-width: 680px;
    margin: 1.5rem auto;
    padding: 1.5rem;
    border: 1px solid var(--hbpmec-border);
    border-radius: 10px;
    background: var(--hbpmec-surface);
    line-height: 1.5;
}

.hbpmec__field,
.hbpmec__group {
    margin: 0 0 var(--hbpmec-space);
}

.hbpmec__group {
    min-width: 0;
    padding: 0;
    border: 0;
}

.hbpmec__group.is-disabled {
    opacity: 0.6;
}

.hbpmec__label,
.hbpmec__legend {
    display: block;
    margin: 0 0 0.5rem;
    padding: 0;
    font: inherit;
    font-weight: 700;
}

.hbpmec__select,
.hbpmec__unit-input input {
    max-width: 100%;
    min-height: var(--hbpmec-control-height);
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--hbpmec-border);
    border-radius: 6px;
    background: var(--hbpmec-surface);
    color: inherit;
    font: inherit;
}

.hbpmec__select {
    width: 100%;
}

.hbpmec__note {
    margin: 0.45rem 0 0;
    color: var(--hbpmec-muted);
    font-size: 0.875em;
}

.hbpmec .hbpmec__range-wrap {
    position: relative;
    margin: 0.25rem 0 0.75rem;
    padding-bottom: 1.35rem;
}

.hbpmec .hbpmec__range {
    display: block;
    width: 100%;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    background-color: transparent;
    cursor: pointer;
    overflow: visible;
    -webkit-appearance: none;
    appearance: none;
}

.hbpmec .hbpmec__ticks {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    pointer-events: none;
}

.hbpmec .hbpmec__tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    transform: translateX(-50%);
}

.hbpmec .hbpmec__tick-line {
    position: absolute;
    top: 10px;
    left: 0;
    width: 1px;
    height: 16px;
    background: rgba(72, 101, 178, 0.45);
}

.hbpmec .hbpmec__tick-label {
    position: absolute;
    top: 27px;
    left: 0;
    color: var(--hbpmec-muted);
    font-size: 0.7em;
    line-height: 1;
    white-space: nowrap;
}

.hbpmec .hbpmec__tick:first-child .hbpmec__tick-label {
    transform: translateX(0);
}

.hbpmec .hbpmec__tick:last-child .hbpmec__tick-label {
    transform: translateX(-100%);
}

.hbpmec__group.is-disabled input:disabled,
.hbpmec__group.is-disabled .hbpmec__range:disabled {
    cursor: not-allowed;
}

.hbpmec__range::-webkit-slider-runnable-track {
    height: 6px;
    border: 1px solid var(--hbpmec-border);
    border-radius: 3px;
    background: var(--hbpmec-border);
}

.hbpmec__range::-webkit-slider-thumb {
    width: var(--hbpmec-slider-thumb-width);
    height: 30px;
    margin-top: -13px;
    border: 1px solid var(--hbpmec-accent);
    border-radius: 3px;
    background: var(--hbpmec-accent);
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.hbpmec__range:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.hbpmec__range::-moz-range-track {
    height: 6px;
    border: 1px solid var(--hbpmec-border);
    border-radius: 3px;
    background: var(--hbpmec-border);
}

.hbpmec__range::-moz-range-thumb {
    width: var(--hbpmec-slider-thumb-width);
    height: 28px;
    border: 1px solid var(--hbpmec-accent);
    border-radius: 3px;
    background: var(--hbpmec-accent);
    box-shadow: none;
}

.hbpmec__range:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

@supports (-moz-appearance: none) {
    .hbpmec .hbpmec__range {
        --hbpmec-slider-thumb-width: 12px;
    }
}

.hbpmec__input-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.hbpmec__unit-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.hbpmec__unit-input input {
    width: 100%;
    min-width: 0;
}

.hbpmec__unit-input input[aria-invalid="true"] {
    border-color: #b42318;
}

.hbpmec__input-error {
    grid-column: 1 / -1;
    color: #b42318;
    font-size: 0.875em;
    line-height: 1.4;
}

.hbpmec__unit-input:nth-child(2) input {
    background: #fbfcfe;
}

.hbpmec__result {
    margin-top: 0.5rem;
    padding: 1.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: var(--hbpmec-result-surface);
    text-align: center;
}

.hbpmec__result-label {
    margin-bottom: 0.5rem;
    color: var(--hbpmec-muted);
    font-size: 0.95em;
    font-weight: 700;
}

.hbpmec__result-values {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
}

.hbpmec__result-primary,
.hbpmec__result-secondary {
    font-variant-numeric: tabular-nums;
}

.hbpmec__result-primary {
    font-size: 1.8em;
    font-weight: 700;
}

.hbpmec__result-secondary {
    align-self: center;
    color: var(--hbpmec-muted);
    font-size: 1.05em;
    font-weight: 600;
}

.hbpmec__reset {
    display: inline-block;
    min-height: var(--hbpmec-control-height);
    margin-top: var(--hbpmec-space);
    padding: 0.55rem 1rem;
    border: 1px solid #b8c0cc;
    border-radius: 6px;
    background: var(--hbpmec-surface);
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.hbpmec__reset:hover,
.hbpmec__reset:focus-visible {
    border-color: var(--hbpmec-accent);
    background: #f5f7fb;
}

.hbpmec__select:focus-visible,
.hbpmec__unit-input input:focus-visible,
.hbpmec__range:focus-visible,
.hbpmec__button:focus-visible,
.hbpmec__comparison td:last-child button:focus-visible,
.hbpmec__reset:focus-visible {
    outline: 2px solid var(--hbpmec-focus);
    outline-offset: 2px;
}

.hbpmec__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 520px) {
    .hbpmec {
        padding: 1rem;
    }

    .hbpmec__input-row {
        gap: 0.55rem;
    }

    .hbpmec .hbpmec__tick--secondary {
        display: none;
    }

    .hbpmec__result-values {
        flex-direction: column;
    }

    .hbpmec .hbpmec__comparison table {
        min-width: 0;
        table-layout: fixed;
        font-size: 0.78em;
    }

    .hbpmec .hbpmec__comparison th,
    .hbpmec .hbpmec__comparison td {
        padding: 0.45rem 0.2rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .hbpmec__result {
        padding: 1rem 0.75rem;
    }

    .hbpmec__result-primary {
        font-size: 1.55em;
    }

    .hbpmec__result-secondary {
        font-size: 1em;
    }

    .hbpmec__comparison th:last-child,
    .hbpmec__comparison td:last-child {
        padding-left: 0.2rem;
    }

    .hbpmec__comparison td:last-child button {
        min-height: 36px;
        padding: 0.3rem 0.35rem;
    }
}

.hbpmec__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: var(--hbpmec-space);
}

.hbpmec__button {
    min-height: var(--hbpmec-control-height);
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--hbpmec-border);
    border-radius: 6px;
    background: var(--hbpmec-surface);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.hbpmec__button:hover,
.hbpmec__button:focus-visible { border-color: var(--hbpmec-accent); background: #f5f7fb; }
.hbpmec__feedback { min-height: 1.5em; margin: 0.4rem 0 0; color: var(--hbpmec-muted); font-size: 0.875em; }
.hbpmec__details { margin-top: 0.85rem; padding-top: 0.7rem; border-top: 1px solid #edf0f4; color: var(--hbpmec-muted); font-size: 0.9em; }
.hbpmec__comparison { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid #edf0f4; }
.hbpmec__comparison-title { margin: 0 0 0.75rem; font-size: 1.1em; font-weight: 700; }
.hbpmec__table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; }
.hbpmec__comparison table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 0.9em; }
.hbpmec__comparison th, .hbpmec__comparison td { padding: 0.55rem 0.5rem; border-bottom: 1px solid #e7eaf0; text-align: right; vertical-align: middle; white-space: nowrap; }
.hbpmec__comparison th { background: #f7f8fa; color: #4b5563; font-size: 0.9em; font-weight: 700; }
.hbpmec__comparison th:first-child, .hbpmec__comparison td:first-child { text-align: left; }
.hbpmec__comparison th:last-child, .hbpmec__comparison td:last-child { padding-left: 0.8rem; border-left: 1px solid #edf0f4; text-align: center; }
.hbpmec__comparison td:last-child button { min-height: 34px; padding: 0.3rem 0.55rem; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; color: #5b6472; font: inherit; font-size: 0.9em; cursor: pointer; }
.hbpmec__comparison td:last-child button:hover { border-color: #9aa5b5; background: #f8fafc; }
.hbpmec__chart { display: grid; gap: 0.5rem; margin: 1rem 0; }
.hbpmec__chart-row { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 0.6rem; align-items: center; min-width: 0; }
.hbpmec__chart-label { min-width: 0; overflow-wrap: anywhere; font-size: 0.8em; font-variant-numeric: tabular-nums; }
.hbpmec__bar-track { min-width: 0; height: 1.5rem; border-radius: 3px; background: rgba(217, 217, 217, 0.65); }
.hbpmec__bar { height: 100%; min-width: 0; border-radius: 3px; background: var(--hbpmec-accent); }
.hbpmec__target span { color: var(--hbpmec-muted); }
.hbpmec__target .hbpmec__input-error { color: #b42318; }
.hbpmec__comparison-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hbpmec__button:disabled { border-color: #e2e5ea; background: #f1f3f5; color: #9aa1ab; cursor: not-allowed; }
.hbpmec__button:disabled:hover { border-color: #e2e5ea; background: #f1f3f5; }
