:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --dark: #1e293b;
    --darker: #0f172a;
    --light: #f8fafc;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

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

body {
    background-color: var(--darker);
    color: var(--light);
    font-family: "Inter", sans-serif;
    line-height: 1.6;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

h3 {
    font-size: 1.4rem;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

button.secondary {
    background-color: var(--dark);
}

button.danger {
    background-color: var(--danger);
}

button.small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

input,
select {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem;
    margin: 0.5rem 0;
    width: 100%;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Компактная карточка */
.card {
    background-color: var(--dark);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--primary);
}

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

.card-bank {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.card-bank i {
    font-size: 1.25rem;
    color: var(--primary);
}

.card-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.card-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.card.expanded .card-content {
    max-height: 1000px;
    transition: max-height 0.5s ease-in;
}

/* Стили для развернутой карточки */
.card-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.card-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-detail-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.card-detail-value {
    font-weight: 500;
    font-size: 1.1rem;
}

.card-detail-value.danger {
    color: #e74c3c !important;
    font-weight: 700;
}

.card-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.debt-progress {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 2rem 0;
    overflow: hidden;
}

.debt-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.payment-item {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.payment-item:last-child {
    margin-bottom: 0;
}

.payment-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.payment-date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

.payment-amount {
    font-weight: 500;
}

.no-payments {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.summary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease;
}

.summary-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.title-main {
    display: flex;
    align-items: center;
    gap: 7px;
}

@media (max-width: 768px) {
    .summary-title button {
        width: 15%; /* Можно 10% или 20% — по вкусу */
        text-align: right; /* Выравнивание внутри кнопки */
    }

    .title-main {
        width: 85%;
    }
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.summary-item {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.summary-item-label {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
}

.summary-item-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal {
    background-color: var(--dark);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1; /* Занимает всё доступное пространство */
    min-width: 0; /* Предотвращает переполнение */
    overflow: hidden; /* На случай длинного текста */
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem; /* Увеличиваем область клика */
    margin-left: auto; /* Сдвигаем к правому краю */
    transition: color 0.2s ease;
    flex-shrink: 0; /* Запрещаем сжиматься */
    width: 2.5rem; /* Фиксированная ширина */
    height: 2.5rem; /* Фиксированная высота */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%; /* Делаем круглой (опционально) */
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-close:hover {
    color: white;
    background: rgba(
        255,
        255,
        255,
        0.1
    ); /* Лёгкий ховер-эффект (опционально) */
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* На мобильных можно сделать кнопку ещё компактнее */
@media (max-width: 768px) {
    .modal-close {
        width: 2rem;
        height: 2rem;
        font-size: 1.3rem;
    }
}

.radio-group {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-option input {
    width: auto;
    margin: 0;
}

.history-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
}

.history-item .date {
    color: #ffffff99;
    display: block;
    margin-bottom: 0.25rem;
}

.history-item.income .amount {
    color: var(--success);
}
.history-item.expense .amount {
    color: var(--danger);
}
.history-item.payment .amount {
    color: var(--primary);
}
.history-item.payment_edit .amount {
    color: var(--warning);
}
.history-item.payment_paid .amount {
    color: var(--success);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .card-details {
        grid-template-columns: 1fr;
    }

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

    .modal-actions {
        flex-direction: column;
    }

    button {
        width: 100%;
        justify-content: center;
    }
}

.error-message {
    color: #ff4444;
    margin: 10px 0;
    min-height: 20px;
}

#loading-state {
    text-align: center;
}

/* ======= спиннер ===========
/* Центрирование блока на экране */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Центрирует по вертикали на всю высоту экрана */
}

/* Сам спиннер */
.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e5e7eb; /* светло-серый */
    border-top-color: var(--primary); /* основной цвет */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Анимация */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* LogIn*/
/* Центрирование #auth-screen */
#auth-screen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    min-width: 300px;
    z-index: 1000;
}

.button-wrapper {
    display: flex;
    justify-content: center;
}

#auth-screen button {
    text-align: center;
    background-color: var(--dark);
}

#auth-screen button:hover {
    background-color: var(--primary-dark);
}

#upcomingPaymentsModal.modal-overlay {
    display: flex;
}

/* outline-стиль для кнопок (пример добавить в CSS):*/

.outline-btn {
    border: 1px solid var(--primary, #1a6eff);
    background: none;
    color: var(--primary, #1a6eff);
    padding: 0.3em 1em;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background 0.15s;
}
.outline-btn.active-outline,
.outline-btn:hover {
    background: var(--primary, #1a6eff);
    color: #fff;
}
