/* Glass Card */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--glass-shadow);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--glass-border);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-family: inherit;
    font-size: var(--font-size-md);
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-size-lg);
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-sm);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Form Elements */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-md);
    font-family: inherit;
    font-size: var(--font-size-md);
    color: var(--text-primary);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.error {
    border-color: var(--accent-danger);
}

.form-error {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--accent-danger);
}

.form-hint {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* Input with Icon */
.input-group {
    position: relative;
}

.input-group .form-input {
    padding-left: 44px;
}

.input-group-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Tags/Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--glass-bg);
    color: var(--text-secondary);
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-success);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.2);
    color: var(--accent-warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

/* Progress Bar */
.progress {
    height: 8px;
    background: var(--glass-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 12px;
    background: var(--glass-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar.success {
    background: var(--gradient-success);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.modal-title {
    font-size: var(--font-size-xl);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Tabs */
.tabs {
    display: flex;
    gap: var(--space-xs);
    background: var(--glass-bg);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.tab {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--gradient-primary);
    color: white;
}

/* Fund Card */
.fund-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}

.fund-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.fund-card.mandatory::before {
    background: var(--fund-mandatory-gradient);
}

.fund-card.variable::before {
    background: var(--fund-variable-gradient);
}

.fund-card.savings::before {
    background: var(--fund-savings-gradient);
}

.fund-amount {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin: var(--space-sm) 0;
}

.fund-percentage {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    background: var(--glass-bg);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: var(--z-dropdown);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: var(--space-md);
}

.nav-link {
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Language Switcher */
.lang-switch {
    display: flex;
    background: var(--glass-bg);
    border-radius: var(--radius-full);
    padding: 2px;
}

.lang-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Autocomplete */
.autocomplete {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-top: var(--space-xs);
    max-height: 200px;
    overflow-y: auto;
    z-index: var(--z-dropdown);
    box-shadow: var(--shadow-lg);
}

.autocomplete-item {
    padding: var(--space-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: var(--glass-bg);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

/* Loader */
.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Dream Background */
.dream-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.15;
    background-size: cover;
    background-position: center;
    filter: blur(30px);
    transition: opacity var(--transition-slow);
}

/* Responsive Navigation */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .nav.mobile-open .nav-links {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        padding: var(--space-md);
        border-bottom: 1px solid var(--glass-border);
    }
}

/* Nested Fund Items */
.fund-items-container {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--glass-border);
}

.fund-group {
    margin-bottom: var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.fund-group-header {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fund-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-md);
    border-bottom: 1px solid var(--glass-border);
}

.fund-item-row:last-child {
    border-bottom: none;
}

.fund-item-name {
    font-size: 1rem;
    flex: 1;
}

.fund-item-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.fund-item-percent {
    width: 55px;
    text-align: right;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 6px;
}

.fund-item-percent:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.fund-item-card-select {
    font-size: 0.9rem;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    max-width: 90px;
}

/* Sticky Balance Bar */
.sticky-balance-bar {
    position: sticky;
    top: 72px;
    /* Height of nav */
    z-index: 100;
    background: rgba(18, 18, 23, 0.8);
    backdrop-filter: blur(20px);
    margin: -1rem -1rem 1.5rem -1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.total-balance-text {
    font-size: 2.5rem !important;
    font-weight: 800 !important;
    letter-spacing: -1px;
}

/* Branded Bank Cards */
.fund-group-header {
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.fund-group:hover .fund-group-header {
    transform: translateX(4px);
}

.fund-group[data-bank="sber"] .fund-group-header {
    background: linear-gradient(90deg, rgba(33, 160, 56, 0.4), rgba(33, 160, 56, 0.1)) !important;
    color: #21a038 !important;
    border-left: 4px solid #21a038;
}

.fund-group[data-bank="vtb"] .fund-group-header {
    background: linear-gradient(90deg, rgba(0, 170, 255, 0.4), rgba(0, 170, 255, 0.1)) !important;
    color: #0af !important;
    border-left: 4px solid #0af;
}

.fund-group[data-bank="tbank"] .fund-group-header {
    background: linear-gradient(90deg, rgba(255, 221, 45, 0.4), rgba(255, 221, 45, 0.1)) !important;
    color: #ffdd2d !important;
    border-left: 4px solid #ffdd2d;
}

.fund-group[data-bank="alpha"] .fund-group-header {
    background: linear-gradient(90deg, rgba(239, 48, 36, 0.4), rgba(239, 48, 36, 0.1)) !important;
    color: #ef3024 !important;
    border-left: 4px solid #ef3024;
}

.fund-group[data-bank="raif"] .fund-group-header {
    background: linear-gradient(90deg, rgba(255, 255, 0, 0.3), rgba(255, 255, 0, 0.1)) !important;
    color: #eeee00 !important;
    border-left: 4px solid #eeee00;
}

/* Card Totals */
.fund-group-footer {
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px dashed var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.fund-group-footer .total-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fund-group-footer .total-value {
    color: var(--text-primary);
}

/* Period Warnings */
.period-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 500;
}

.pulse-primary {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

/* Custom Calendar Styling (Simple reset for native picker) */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.hover-scale {
    transition: transform var(--transition-normal);
}

.hover-scale:hover {
    transform: scale(1.02);
}

.hover-bright:hover {
    filter: brightness(1.2);
}


/* Payment Reminder Styles */
.fund-item-row.payment-due {
    background: rgba(239, 68, 68, 0.4) !important;
    animation: glow-red 1.5s infinite alternate;
    position: relative;
    border-radius: var(--radius-sm);
    margin: 2px 0;
}

@keyframes glow-red {
    from {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
    }

    to {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
    }
}

.btn-pay-item {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gradient-success);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.fund-item-row.payment-due:hover {
    background: rgba(239, 68, 68, 0.6) !important;
}

.fund-item-row.payment-due:hover .btn-pay-item {
    opacity: 1;
    pointer-events: auto;
}

.fund-item-row.payment-due:hover .fund-item-controls {
    opacity: 0.1;
    pointer-events: none;
}

.fund-item-day {
    width: 45px;
    text-align: center;
    font-size: 11px;
    padding: 2px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: white;
}

/* Admin Tooltip Styles */
.admin-tooltip {
    position: fixed;
    z-index: 10000;
    width: 300px;
    max-width: 90vw;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
    border: 1px solid rgba(138, 43, 226, 0.5);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(138, 43, 226, 0.2);
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Заголовок подсказки убран */


.admin-tooltip-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    margin-bottom: var(--space-sm);
    white-space: pre-wrap;
}

.admin-tooltip-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-tooltip-editor textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: white;
    padding: var(--space-sm);
    font-family: inherit;
    font-size: var(--font-size-sm);
    resize: vertical;
}

.admin-tooltip-editor textarea:focus {
    outline: none;
    border-color: rgba(138, 43, 226, 0.6);
}

/* Fund Item Day Input */
.fund-item-day {
    width: 45px;
    text-align: center;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 6px;
}

.fund-item-day:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Collapsible Card */
.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.collapsible-icon {
    transition: transform 0.3s ease;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.collapsible-card.collapsed .collapsible-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: var(--space-md);
}

.collapsible-card.collapsed .collapsible-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Tooltip Toggle Switch */
.tooltip-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.tooltip-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tooltip-toggle input {
    display: none;
}

.toggle-slider {
    width: 32px;
    height: 18px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 9px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.tooltip-toggle input:checked+.toggle-slider {
    background: var(--accent-primary);
}

.tooltip-toggle input:checked+.toggle-slider::after {
    transform: translateX(14px);
}