:root {
    color-scheme: dark;
    interpolate-size: allow-keywords;
    --page: #1d1d20;
    --panel: #3c3c3f;
    --panel-top: #303033;
    --panel-bottom: #303033;
    --control: #2f2f31;
    --control-soft: #45454b;
    --control-active: #55555f;
    --border: #75757d;
    --border-soft: #55555c;
    --text: #f6f3f6;
    --muted: #c6c1c8;
    --subtle: #918d96;
    --accent-start: #5b36f4;
    --accent-end: #b313ef;
    --success: #22c08d;
    --radius-panel: 16px;
    --radius-control: 12px;
    --shadow: 0 22px 56px rgb(0 0 0 / 0.34);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.app-shell {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 20px 18px;
    background: var(--page);
    color: var(--text);
}

.calculator-stack {
    width: min(100%, 620px);
    display: grid;
    gap: 12px;
}

.calculator-panel {
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-panel);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.calculator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 72px;
    padding: 18px 30px;
    background: var(--panel-top);
}

.panel-title-group {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.panel-icon {
    width: 39px;
    height: 39px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 10px;
    background: #626267;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15);
}

.panel-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #ffffff;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.calculator-header h1 {
    margin: 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: 0;
}

.panel-status {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.calculator-body {
    padding: 20px 30px;
}

.calculator-form {
    display: grid;
    gap: 14px;
}

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

.field-group {
    display: grid;
    gap: 7px;
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 20px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.field-label-row span {
    color: var(--subtle);
    font-size: 12px;
    font-weight: 600;
}

.field-label-row > span:first-child {
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.form-input,
.form-select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--control);
    color: var(--text);
    padding: 0 15px;
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.form-select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 20px) 21px,
        calc(100% - 14px) 21px;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 42px;
}

.form-input:focus,
.form-select:focus {
    border-color: #9d8dff;
    background: #333337;
    box-shadow: 0 0 0 3px rgb(139 108 255 / 0.18);
}

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

.select-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    background: var(--control);
    color: var(--muted);
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.select-chip:hover {
    border-color: var(--border);
    background: #353539;
}

.select-chip:focus-within {
    border-color: #9d8dff;
    box-shadow: 0 0 0 3px rgb(139 108 255 / 0.18);
}

.select-chip input[type="checkbox"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.select-chip span.label {
    min-width: 0;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
}

.select-chip span.indicator {
    width: 22px;
    height: 22px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #29292c;
    color: transparent;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.select-chip span.indicator::after {
    content: "";
    width: 10px;
    height: 6px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-1px) rotate(-45deg);
}

.select-chip.selected {
    border-color: rgb(34 192 141 / 0.8);
    background: rgb(34 192 141 / 0.12);
    color: var(--text);
}

.select-chip.selected span.indicator {
    border-color: var(--success);
    background: var(--success);
    color: #ffffff;
}

.error-message {
    border: 1px solid rgb(255 103 103 / 0.4);
    border-radius: var(--radius-control);
    background: rgb(255 103 103 / 0.12);
    color: #ffd6d6;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.35;
}

.breakdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.breakdown-row span:last-child {
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}

.provider-panel {
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-panel);
    background: var(--panel-bottom);
    box-shadow: var(--shadow);
}

.provider-panel > summary {
    min-height: 86px;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 20px;
    padding: 16px 30px;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    transition: background 160ms ease;
}

.provider-panel > summary:hover {
    background: rgb(255 255 255 / 0.025);
}

.provider-panel > summary::-webkit-details-marker {
    display: none;
}

.provider-panel > summary:focus-visible {
    outline: 2px solid #9d8dff;
    outline-offset: -4px;
}

.provider-logo-cell {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.provider-logo {
    display: block;
    max-width: 100%;
    object-fit: contain;
}

.provider-logo--gls {
    width: 104px;
    max-height: 48px;
}

.provider-logo--post {
    width: 52px;
    height: 52px;
}

.provider-total {
    min-width: 0;
}

.provider-total-label {
    display: block;
    margin-bottom: 3px;
    color: var(--subtle);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.provider-total strong {
    display: block;
    color: var(--text);
    font-size: 30px;
    font-weight: 800;
    line-height: 1.05;
    white-space: nowrap;
}

.price-value {
    position: relative;
    display: grid !important;
    block-size: 1.08em;
    overflow: hidden;
    align-items: center;
}

.price-value-number {
    grid-area: 1 / 1;
    display: block;
    transform: translateY(0);
    will-change: transform, opacity;
}

.provider-toggle {
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 220ms ease;
}

.provider-panel[open] .provider-toggle {
    transform: translateY(3px) rotate(225deg);
}

.provider-panel::details-content {
    block-size: 0;
    overflow: clip;
    opacity: 0;
    transition:
        block-size 220ms ease,
        content-visibility 220ms allow-discrete,
        opacity 160ms ease;
}

.provider-panel[open]::details-content {
    block-size: auto;
    opacity: 1;
}

.provider-breakdown-body {
    padding: 17px 30px 20px;
    border-top: 1px solid var(--border-soft);
    transform: translateY(-5px);
    transition: transform 220ms ease;
}

.provider-panel[open] .provider-breakdown-body {
    transform: translateY(0);
}

.provider-breakdown-body h2 {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.provider-breakdown-body > .error-message:not(.hidden) {
    margin-bottom: 14px;
}

.provider-breakdown-list {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hidden {
    display: none !important;
}

@media (max-width: 620px) {
    body.app-shell {
        align-items: start;
        padding: 16px;
    }

    .calculator-header,
    .calculator-body,
    .provider-panel > summary,
    .provider-breakdown-body {
        padding-left: 20px;
        padding-right: 20px;
    }

    .calculator-header {
        align-items: flex-start;
        min-height: auto;
    }

    .calculator-header h1 {
        font-size: 20px;
    }

    .panel-status {
        display: none;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .primary-fields {
        grid-template-columns: 1fr;
    }

    .provider-panel > summary {
        grid-template-columns: 86px minmax(0, 1fr) 18px;
        gap: 14px;
    }

    .provider-logo--gls {
        width: 82px;
    }

    .provider-logo--post {
        width: 48px;
        height: 48px;
    }

    .provider-total strong {
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
