.atps {
    --atps-bg: #f7faf9;
    --atps-surface: #ffffff;
    --atps-border: #d9e3df;
    --atps-border-strong: #a9bbb4;
    --atps-text: #1f2d2a;
    --atps-muted: #5e6d68;
    --atps-primary: #1c7c6b;
    --atps-primary-dark: #115c50;
    --atps-accent: #b56b18;
    --atps-soft: #eaf5f2;
    --atps-warning: #fff6e7;
    color: var(--atps-text);
    font-family: inherit;
    letter-spacing: 0;
}

.atps *,
.atps *::before,
.atps *::after {
    box-sizing: border-box;
}

.atps [hidden] {
    display: none !important;
}

.atps a {
    color: var(--atps-primary-dark);
}

.atps-form {
    display: grid;
    gap: 18px;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
}

.atps-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--atps-border);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, var(--atps-bg) 100%);
}

.atps-hero h2 {
    margin: 0 0 6px;
    font-size: 1.55rem;
    line-height: 1.35;
}

.atps-hero p,
.atps-muted,
.atps-notes p {
    margin: 0;
    color: var(--atps-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

.atps-source,
.atps-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--atps-border-strong);
    background: var(--atps-surface);
    color: var(--atps-primary-dark);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.atps-source:hover,
.atps-reset:hover {
    border-color: var(--atps-primary);
    background: var(--atps-soft);
}

.atps-panel {
    padding: 18px;
    border: 1px solid var(--atps-border);
    border-radius: 8px;
    background: var(--atps-surface);
}

.atps-panel h3 {
    margin: 0 0 14px;
    font-size: 1.08rem;
    line-height: 1.45;
}

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

.atps-choice {
    display: block;
    min-width: 0;
}

.atps-choice input,
.atps-segment input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.atps-choice__body {
    display: grid;
    gap: 4px;
    min-height: 96px;
    padding: 14px;
    border: 1px solid var(--atps-border);
    border-radius: 8px;
    background: #fbfdfc;
    cursor: pointer;
}

.atps-choice input:checked + .atps-choice__body {
    border-color: var(--atps-primary);
    background: var(--atps-soft);
    box-shadow: 0 0 0 2px rgba(28, 124, 107, 0.12);
}

.atps-choice input:focus-visible + .atps-choice__body,
.atps-segment input:focus-visible + span {
    outline: 3px solid rgba(28, 124, 107, 0.28);
    outline-offset: 2px;
}

.atps-choice__title {
    font-weight: 800;
    line-height: 1.45;
}

.atps-choice__text {
    color: var(--atps-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.atps-options {
    display: grid;
    gap: 16px;
}

.atps-field-group,
.atps-field-row {
    display: grid;
    gap: 10px;
}

.atps-field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.atps-field-row label {
    display: grid;
    gap: 7px;
}

.atps-label {
    display: block;
    color: var(--atps-text);
    font-size: 0.92rem;
    font-weight: 800;
}

.atps input[type="number"],
.atps select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--atps-border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--atps-text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
}

.atps input[type="number"]:focus,
.atps select:focus {
    border-color: var(--atps-primary);
    outline: 3px solid rgba(28, 124, 107, 0.18);
}

.atps select {
    appearance: auto;
}

.atps-helper {
    grid-column: 1 / -1;
    margin: -2px 0 0;
    color: var(--atps-muted);
    font-size: 0.9rem;
    line-height: 1.65;
}

.atps-segments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.atps-segment {
    position: relative;
    display: inline-flex;
}

.atps-segment span {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--atps-border-strong);
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}

.atps-segment input:checked + span {
    border-color: var(--atps-primary);
    background: var(--atps-primary);
    color: #fff;
}

.atps-private-toggle label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.atps-private-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--atps-primary);
}

.atps-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.atps-layout > [data-atps-private-panel] {
    grid-column: 1;
}

.atps-result {
    grid-column: 2;
    grid-row: 1 / span 2;
    position: sticky;
    top: 24px;
    display: grid;
    gap: 12px;
}

.atps-result__label {
    color: var(--atps-muted);
    font-size: 0.9rem;
    font-weight: 800;
}

.atps-result__total {
    color: var(--atps-primary-dark);
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.2;
}

.atps-mobile-total {
    display: none;
}

.atps-result__meta,
.atps-adjustment,
.atps-empty {
    margin: 0;
    color: var(--atps-muted);
    font-size: 0.92rem;
    line-height: 1.65;
}

.atps-adjustment {
    padding: 10px 12px;
    border: 1px solid #f0d8ad;
    border-radius: 8px;
    background: var(--atps-warning);
    color: #6b430f;
}

.atps-breakdown {
    display: grid;
    gap: 12px;
}

.atps-breakdown h4 {
    margin: 4px 0 0;
    font-size: 0.95rem;
}

.atps-lines {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.atps-lines li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--atps-border);
}

.atps-lines small {
    display: block;
    margin-top: 2px;
    color: var(--atps-muted);
    line-height: 1.5;
}

.atps-details {
    border-top: 1px solid var(--atps-border);
}

.atps-details:first-of-type {
    border-top: 0;
}

.atps-details summary {
    padding: 14px 0;
    font-weight: 900;
    cursor: pointer;
}

.atps-details__body {
    display: grid;
    gap: 10px;
    padding-bottom: 14px;
}

.atps-service {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 136px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--atps-border);
    border-radius: 8px;
    background: #fbfdfc;
}

.atps-service__label {
    font-weight: 800;
    line-height: 1.55;
}

.atps-service__note {
    margin-top: 4px;
    color: var(--atps-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.atps-price {
    display: inline-block;
    margin-top: 6px;
    color: var(--atps-accent);
    font-size: 0.9rem;
    font-weight: 900;
}

.atps-service__inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    color: var(--atps-muted);
    font-weight: 700;
}

.atps-notes {
    padding: 16px 18px;
    border: 1px solid var(--atps-border);
    border-radius: 8px;
    background: var(--atps-bg);
}

.atps-notes h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.atps-notes ul {
    margin: 0 0 10px 1.2em;
    padding: 0;
    color: var(--atps-muted);
    line-height: 1.75;
}

.atps__loading {
    padding: 18px;
    border: 1px solid var(--atps-border);
    border-radius: 8px;
    background: var(--atps-bg);
}

.atps__loading--error {
    border-color: #e0b4a8;
    background: #fff4f1;
    color: #7b2f20;
}

@media (max-width: 900px) {
    .atps-choice-grid,
    .atps-layout {
        grid-template-columns: 1fr;
    }

    .atps-result {
        grid-column: auto;
        grid-row: auto;
        position: static;
    }
}

@media (max-width: 640px) {
    .atps {
        max-width: 100%;
        overflow-x: clip;
        -webkit-text-size-adjust: 100%;
    }

    .atps-form {
        padding-bottom: 86px;
    }

    .atps-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 18px;
    }

    .atps-field-row {
        grid-template-columns: 1fr;
    }

    .atps-service {
        grid-template-columns: 1fr;
    }

    .atps-service__inputs {
        max-width: 180px;
    }

    .atps-result__total {
        font-size: 1.7rem;
    }

    .atps-mobile-total {
        position: fixed;
        right: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 58px;
        padding: 10px 14px;
        border: 1px solid var(--atps-border-strong);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 8px 24px rgba(17, 92, 80, 0.18);
        backdrop-filter: blur(8px);
    }

    .atps-mobile-total span {
        color: var(--atps-muted);
        font-size: 0.86rem;
        font-weight: 800;
        line-height: 1.35;
    }

    .atps-mobile-total strong {
        color: var(--atps-primary-dark);
        font-size: 1.45rem;
        font-weight: 900;
        line-height: 1;
        white-space: nowrap;
    }
}
