:root {
    --md-sys-color-primary: #0b57d0;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d3e3fd;
    --md-sys-color-on-primary-container: #041e49;
    --md-sys-color-surface: #f8fafd;
    --md-sys-color-surface-container: #ffffff;
    --md-sys-color-on-surface: #1f1f1f;
    --md-sys-color-on-surface-variant: #444746;
    --md-sys-color-outline: #747775;
    --md-elevation-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-elevation-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px;
}

/* App Bar (Header) */
.header {
    background-color: var(--md-sys-color-surface-container);
    box-shadow: var(--md-elevation-1);
    padding: 12px 0;
    z-index: 10;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-centered {
    justify-content: center !important;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 30px; /* Увеличили размер по просьбе пользователя */
    font-weight: 800; /* Сделали более массивным */
    color: var(--md-sys-color-primary);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}

.tg-btn-small {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.tg-btn-small:hover {
    background-color: #b4cff9;
    box-shadow: var(--md-elevation-1);
}

/* Premium Telegram Header Button */
.tg-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #0088cc 0%, #0077b5 50%, #005f99 100%);
    color: #ffffff;
    text-decoration: none;
    padding: 12px 32px;
    border-radius: 100px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
}

.tg-header-btn svg {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.tg-header-btn:hover {
    background: linear-gradient(135deg, #009ee0 0%, #0088cc 50%, #006bb3 100%);
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.45);
    transform: translateY(-1px);
}

.tg-header-btn:hover svg {
    transform: scale(1.15);
}

.tg-header-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 136, 204, 0.3);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 40px 0 20px;
}

.hero h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.2;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #1a1a2e 0%, #0b57d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 18px;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
}

.hero-desc {
    font-size: 15px;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
}

/* Calculator Card */
.calculator-section {
    padding: 16px 0 48px;
}

.calc-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--md-elevation-1);
}

/* MD3 Outlined Text Fields */
.md-input {
    position: relative;
    margin-bottom: 24px;
}

.md-input input {
    width: 100%;
    padding: 16px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px; /* Standard MD3 text field radius */
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    background: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.md-input label {
    position: absolute;
    top: 16px;
    left: 12px;
    padding: 0 4px;
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 24px);
}

.md-input input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 15px 15px; /* Offset the 2px border */
}

/* Floating label logic */
.md-input input:focus + label,
.md-input input:not(:placeholder-shown) + label {
    top: -12px;
    font-size: 12px;
    color: var(--md-sys-color-primary);
}

.md-input input:not(:focus):not(:placeholder-shown) + label {
    color: var(--md-sys-color-on-surface-variant);
}

.md-input small {
    display: block;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
    margin-left: 16px;
    font-size: 12px;
}

/* Layout for Region Row */
.form-group-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.form-group-row .md-input {
    margin-bottom: 0;
}

.md-select {
    flex: 2;
}

.pm-input-container {
    flex: 1;
}

.md-input select {
    width: 100%;
    padding: 16px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.md-input select:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 15px 15px;
}

.md-input select:focus + label,
.md-input select:valid + label {
    top: -12px;
    font-size: 12px;
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container);
}

.md-input select:not(:focus):valid + label {
    color: var(--md-sys-color-on-surface-variant);
}

.md-input input[list] {
    width: 100%;
    padding: 16px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    background: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.md-input input[list]:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 15px 15px;
}

.md-input input[list]:focus + label,
.md-input input[list]:not(:placeholder-shown) + label {
    top: -8px;
    font-size: 12px;
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container);
}

.md-input input[list]:not(:focus):not(:placeholder-shown) + label {
    color: var(--md-sys-color-on-surface-variant);
}

.md-input .md-textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    background: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    resize: vertical;
}

.md-input textarea:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 15px 15px;
}

.md-input textarea:focus + label,
.md-input textarea:not(:placeholder-shown) + label {
    top: -12px;
    font-size: 12px;
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container);
}

.md-input textarea:not(:focus):not(:placeholder-shown) + label {
    color: var(--md-sys-color-on-surface-variant);
}

/* Removed native custom arrow as Choices.js renders its own */

/* Filled Button (Material 3) */
.calc-btn {
    width: 100%;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 12px 24px;
    height: 48px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    border-radius: 100px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    margin-top: 8px;
}

.calc-btn:hover {
    box-shadow: var(--md-elevation-1);
    background-color: #0d47a1;
}

.calc-btn:active {
    background-color: #0a3d91;
}

/* Result Block */
.result-block {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid #e0e2e0;
    animation: fadeIn 0.4s ease;
}

.result-block.hidden {
    display: none;
}

.result-block h2 {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 16px;
}

.result-text {
    font-size: 16px;
    margin-bottom: 24px;
    padding: 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.result-text.success {
    background-color: #edf5ea;
    color: #0f5223;
}

.result-text.danger {
    background-color: #fce8e8;
    color: #8c1d18;
}

.calc-breakdown {
    margin-top: 12px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    font-size: 14px;
    border-left: 3px solid currentColor;
}

/* CTA Box */
.cta-box {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 24px;
    border-radius: 16px;
}

.cta-box h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 12px;
}

.cta-box p {
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.tg-btn-large {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    text-decoration: none;
    height: 48px;
    padding: 0 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    transition: background-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.tg-btn-large:hover {
    box-shadow: var(--md-elevation-1);
    background-color: #0d47a1;
}

.footer {
    text-align: center;
    padding: 28px 0 32px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 13px;
}

.footer-copy {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: #888c8a;
    letter-spacing: 0.2px;
    line-height: 1.5;
    text-align: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Ripple Base */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple-animation 0.6s linear;
    background-color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--md-sys-color-surface-container);
    padding: 32px;
    border-radius: 24px;
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: var(--md-elevation-2);
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 24px;
    font-weight: bold;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.close-modal:hover {
    background-color: var(--md-sys-color-outline);
    color: white;
}

/* Choices.js Material Design Override */
.choices {
    margin-bottom: 0;
}
.choices__inner {
    background-color: transparent !important;
    border: 1px solid var(--md-sys-color-outline) !important;
    border-radius: 4px !important;
    padding: 13px 16px 13px !important; /* Compact balanced padding */
    min-height: 52px !important;
    font-size: 16px !important;
    color: var(--md-sys-color-on-surface) !important;
    box-shadow: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
}
.is-focused .choices__inner, .is-open .choices__inner {
    border-color: var(--md-sys-color-primary) !important;
    border-width: 2px !important;
    padding: 12px 15px 12px !important; /* Offset border width */
}
.choices__list--dropdown {
    border-radius: 8px !important;
    border: 1px solid var(--md-sys-color-outline) !important;
    box-shadow: var(--md-elevation-2) !important;
    z-index: 1000 !important;
    background-color: var(--md-sys-color-surface-container) !important;
    margin-top: 4px !important;
    padding: 4px 0 !important;
}
.choices__list--dropdown .choices__item {
    font-size: 16px !important;
    padding: 6px 16px !important; /* Уменьшаем высоту строки для компактности списка */
    line-height: 1.2 !important;
    color: var(--md-sys-color-on-surface) !important;
}
.choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: var(--md-sys-color-surface) !important;
    color: var(--md-sys-color-primary) !important;
}
.choices[data-type*="select-one"] .choices__inner {
    padding-bottom: 13px !important;
    padding-right: 16px !important; /* Убираем отступ, который был под стрелочку */
}
.choices[data-type*="select-one"]::after { /* The arrow */
    display: none !important; /* Полностью скрываем треугольник справа */
}
.choices.is-open[data-type*="select-one"]::after {
    display: none !important;
}

/* Hardcode the label to float when Choices is loaded */
.md-select label {
    top: -8px !important;
    font-size: 12px !important;
    color: var(--md-sys-color-on-surface-variant) !important;
    background-color: var(--md-sys-color-surface-container) !important;
    z-index: 10 !important;
}
.is-focused + label, .is-open + label {
    color: var(--md-sys-color-primary) !important;
}

@media (max-width: 600px) {
    .hero {
        padding: 28px 0 14px;
    }

    .hero h1 {
        font-size: 26px;
    }

    .hero-subtitle {
        font-size: 15px;
    }

    .hero-desc {
        font-size: 13px;
    }

    .calc-card {
        padding: 24px 16px;
        border-radius: 16px;
    }

    /* Stack region row vertically on mobile */
    .form-group-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }

    .form-group-row .md-input {
        margin-bottom: 24px;
    }

    .md-select {
        flex: unset;
        width: 100%;
    }

    .pm-input-container {
        flex: unset;
        width: 100%;
    }

    /* Shrink long label text on income field */
    #monthly-income + label {
        font-size: 13px;
        white-space: normal;
        line-height: 1.2;
        top: 10px;
    }
    #monthly-income:focus + label,
    #monthly-income:not(:placeholder-shown) + label {
        top: -14px;
        font-size: 11px;
        white-space: nowrap;
    }

    .header .container {
        gap: 8px;
    }

    .logo {
        font-size: 22px;
    }

    .tg-btn-small {
        padding: 8px 14px;
        font-size: 12px;
    }
}
