/* COMPLETE BUY-MODAL.CSS - All updates included */

/* MODAL CONTAINER - highest z-index and positioning */
.modal-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 9999 !important; /* MAXIMUM z-index */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    overflow-y: auto !important;
}

/* MODAL CONTENT - center and raise higher */
.territory-details-modal {
    background: white !important;
    border-radius: 12px !important;
    width: 100% !important;
    max-width: 900px !important;
    max-height: 90vh !important;
    overflow: hidden !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
    position: relative !important;
    z-index: 10000 !important; /* EVEN HIGHER */
    display: flex !important;
    flex-direction: column !important;
}

/* TERRITORY NAVIGATION CONTROLS */
.territory-navigation {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 15px !important;
    margin-bottom: 15px !important;
    padding: 12px 16px !important;
    background: rgba(40, 167, 69, 0.1) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(40, 167, 69, 0.2) !important;
}

/* Navigation Buttons */
.nav-btn {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    background: #28a745 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-width: 100px !important;
    justify-content: center !important;
}

.nav-btn:hover:not(:disabled) {
    background: #218838 !important;
    transform: translateY(-1px) !important;
}

.nav-btn:disabled {
    background: #6c757d !important;
    color: #adb5bd !important;
    cursor: not-allowed !important;
    transform: none !important;
    opacity: 0.6 !important;
}

.nav-btn svg {
    width: 16px !important;
    height: 16px !important;
    fill: currentColor !important;
}

.nav-btn:focus {
    outline: 2px solid rgba(40, 167, 69, 0.5) !important;
    outline-offset: 2px !important;
}

.nav-btn:active:not(:disabled) {
    transform: translateY(0px) !important;
    background: #1e7e34 !important;
}

/* Territory Counter */
.territory-counter {
    flex: 1 !important;
    text-align: center !important;
    font-weight: 600 !important;
    color: #28a745 !important;
    font-size: 16px !important;
    background: white !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    border: 1px solid rgba(40, 167, 69, 0.3) !important;
}

.territory-counter.success {
    background: rgba(40, 167, 69, 0.1) !important;
    color: #28a745 !important;
    border-color: rgba(40, 167, 69, 0.3) !important;
}

.territory-counter.error {
    background: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
    border-color: rgba(220, 53, 69, 0.3) !important;
}

/* Loading State for Navigation */
.territory-navigation.loading {
    opacity: 0.5 !important;
    pointer-events: none !important;
}

.territory-navigation.loading .territory-counter {
    background: #f8f9fa !important;
    color: #6c757d !important;
    border-color: #e9ecef !important;
}

/* MODAL HEADER - fixed height */
.modal-header {
    padding: 20px 24px !important;
    border-bottom: 1px solid #e9ecef !important;
    display: flex !important;
    flex-direction: column !important; /* Column layout for navigation */
    background: white !important;
    border-radius: 12px 12px 0 0 !important;
    position: relative !important;
    z-index: 10001 !important;
}

/* Header Title Row - proper alignment of all elements */
.header-title-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important; /* Center all elements vertically */
    width: 100% !important;
    min-height: 40px !important; /* Minimum height like input fields */
}

/* Modal Title - baseline alignment with text fields */
.modal-header h2 {
    margin: 0 !important;
    font-size: 16px !important; /* Same size as form */
    font-weight: 500 !important;
    color: #333 !important;
    flex: 1 !important;
    margin-right: 20px !important;
    font-family: var(--font-body) !important; /* Same font as everywhere */
    line-height: 1.5 !important; /* Same line height as input */
    display: flex !important;
    align-items: center !important; /* Center vertically */
    height: 40px !important; /* Same height as input fields */
    padding: 0 !important; /* Remove padding that might mess alignment */
}

/* Header Actions - alignment */
.header-actions {
    display: flex !important;
    align-items: center !important; /* Center vertically */
    gap: 15px !important;
    flex-wrap: wrap !important;
    height: 40px !important; /* Fixed height */
}

/* Purchase Controls - precise alignment */
.purchase-controls {
    display: flex !important;
    align-items: center !important; /* Center elements vertically */
    gap: 10px !important;
    flex-wrap: wrap !important;
    height: 40px !important; /* Same height as title */
}

/* Input Fields - standardized height */
.purchase-controls input {
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    min-width: 120px !important;
    height: 40px !important; /* Fixed height */
    line-height: 1.5 !important; /* Same as title */
    box-sizing: border-box !important; /* Include padding in height */
    vertical-align: middle !important;
}

.purchase-controls input:disabled {
    background: #f8f9fa !important;
    color: #6c757d !important;
}

/* Purchase Button - same height and font */
#purchaseRetireBtn {
    background: #28a745 !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
    font-family: var(--font-body) !important;
    font-size: 16px !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    transition: all 0.2s ease !important;
    height: 40px !important; /* Exactly same height */
    line-height: 1.5 !important; /* Same line height */
    box-sizing: border-box !important;
    vertical-align: middle !important;
    display: flex !important;
    align-items: center !important; /* Center text vertically */
    justify-content: center !important;
}

#purchaseRetireBtn:hover:not(:disabled) {
    background: #218838 !important;
    transform: translateY(-1px) !important;
}

#purchaseRetireBtn:disabled {
    background: #6c757d !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Close Modal Button - alignment */
.close-modal {
    background: none !important;
    border: none !important;
    font-size: 24px !important;
    color: #6c757d !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important; /* Slightly smaller than input fields */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    align-self: center !important; /* Align center relative to other elements */
}

.close-modal:hover {
    background: #f8f9fa !important;
    color: #333 !important;
}

/* MODAL BODY - scrollable */
.modal-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 0 !important;
    background: white !important;
    transition: opacity 0.2s ease-in-out !important;
}

.modal-body.switching {
    opacity: 0.7 !important;
}

/* TABS */
.territory-details-tabs {
    display: flex !important;
    border-bottom: 2px solid #e9ecef !important;
    background: #f8f9fa !important;
    padding: 0 24px !important;
}

.tab-button {
    background: none !important;
    border: none !important;
    padding: 12px 20px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    color: #6c757d !important;
    border-bottom: 3px solid transparent !important;
    transition: all 0.2s ease !important;
}

.tab-button.active {
    color: #28a745 !important;
    border-bottom-color: #28a745 !important;
    background: rgba(40, 167, 69, 0.1) !important;
}

.tab-button:hover {
    color: #28a745 !important;
    background: rgba(40, 167, 69, 0.05) !important;
}

/* TAB CONTENT */
.tab-content {
    display: none !important;
    padding: 24px !important;
    background: white !important;
}

.tab-content.active {
    display: block !important;
}

/* COMPACT GRID 3x3 - maximally compressed */
.details-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important; /* Exactly 3 columns */
    gap: 8px !important; /* Minimal gaps */
    margin: 10px 0 !important; /* Compressed margins */
}

/* Grid elements - compact */
.detail-item {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important; /* Minimal gap between label and value */
    padding: 8px !important; /* Compressed padding */
    background: #f8f9fa !important;
    border-radius: 6px !important; /* Smaller radius */
    border-left: 3px solid #28a745 !important; /* Thinner strip */
}

/* Labels in grid - font 12px */
.detail-label {
    font-size: 12px !important;
    color: #6c757d !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important; /* Less letter-spacing */
    line-height: 1.2 !important; /* Compressed line height */
}

/* Values in grid - font 12px */
.detail-value {
    font-size: 12px !important;
    color: #333 !important;
    font-weight: 500 !important;
    line-height: 1.3 !important; /* Compressed line height */
}

/* Special styling for values */
.vintage-badge {
    background: #28a745 !important;
    color: white !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
}

.credits-available {
    color: #28a745 !important;
    font-weight: 700 !important;
    font-size: 1.1rem !important;
}

.price-per-credit {
    color: #28a745 !important;
    font-weight: 700 !important;
    font-size: 1.1rem !important;
}

/* MAP CONTAINER - compact height */
#territory-map-container {
    height: 200px !important; /* Smaller height to save space */
    width: 100% !important;
    border-radius: 6px !important; /* Smaller radius */
    overflow: hidden !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important; /* Smaller shadow */
    background: #e9ecef !important;
    position: relative !important;
    z-index: 1 !important; /* LOW z-index for map */
}

/* Leaflet Map Fixes */
.leaflet-container {
    height: 100% !important;
    width: 100% !important;
    z-index: 1 !important; /* DOESN'T CONFLICT with modal */
}

.leaflet-control-container {
    z-index: 10 !important; /* Map controls visible but below modal */
}

.leaflet-popup {
    z-index: 20 !important; /* Map popups */
}

/* PROJECT NOTES - compact */
.project-notes {
    background: #f8f9fa !important;
    padding: 12px !important; /* Less padding */
    border-radius: 6px !important;
    border-left: 3px solid #17a2b8 !important; /* Thinner strip */
}

.project-notes p {
    margin: 0 !important;
    line-height: 1.4 !important; /* Compressed line height */
    color: #333 !important;
    font-size: 12px !important; /* Same size as grid */
}

/* VALIDATION INFO - also compact */
.validation-info {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important; /* 2 columns for validation */
    gap: 8px !important; /* Same gap as main grid */
    margin-bottom: 15px !important; /* Compressed margin */
}

/* Validation Items - compact */
.validation-item {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    padding: 8px !important; /* Same padding as detail-item */
    background: #f8f9fa !important;
    border-radius: 6px !important;
}

/* Validation Labels and Values - font 12px */
.validation-label {
    font-size: 12px !important;
    color: #6c757d !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    line-height: 1.2 !important;
}

.validation-value {
    font-size: 12px !important;
    color: #333 !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
}

.validation-value a {
    color: #007bff !important;
    text-decoration: none !important;
}

.validation-value a:hover {
    text-decoration: underline !important;
}

/* STANDARDS LIST */
.standards-container h4 {
    margin: 30px 0 15px 0 !important;
    color: #333 !important;
    font-size: 14px !important; /* Same as section headers */
    font-weight: 600 !important;
}

/* Standards Items - compact */
.standard-item {
    display: flex !important;
    align-items: flex-start !important;
    gap: 10px !important; /* Less gap */
    padding: 10px !important; /* Less padding */
    background: #f8f9fa !important;
    border-radius: 6px !important;
    margin-bottom: 8px !important; /* Less margin */
    border-left: 3px solid #28a745 !important; /* Thinner strip */
}

.standard-icon {
    font-size: 1.2rem !important;
    flex-shrink: 0 !important;
}

.standard-details h4 {
    margin: 0 0 3px 0 !important; /* Less margin */
    color: #333 !important;
    font-size: 12px !important; /* Font 12px */
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

.standard-details p {
    margin: 0 !important;
    color: #6c757d !important;
    font-size: 12px !important; /* Font 12px */
    line-height: 1.3 !important;
}

.standard-symbol {
    background: #28a745 !important;
    color: white !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
}

/* NO STANDARDS STATE - compact */
.no-standards {
    text-align: center !important;
    padding: 20px 10px !important; /* Less padding */
    color: #6c757d !important;
}

.no-standards h3 {
    margin: 0 0 8px 0 !important; /* Less margin */
    color: #495057 !important;
    font-size: 14px !important; /* Same as section headers */
    font-weight: 600 !important;
}

.no-standards p {
    margin: 0 !important;
    font-size: 12px !important; /* Font 12px */
    line-height: 1.4 !important;
}

/* DOCUMENTS LIST - compact */
.documents-list {
    margin-top: 20px !important;
}

.document-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important; /* Less gap */
    padding: 8px 10px !important; /* Less padding */
    background: #f8f9fa !important;
    border-radius: 6px !important;
    margin-bottom: 6px !important; /* Less margin */
    transition: background 0.2s ease !important;
}

.document-item:hover {
    background: #e9ecef !important;
}

.document-icon {
    font-size: 1.2rem !important;
    color: #007bff !important;
}

.document-link {
    color: #007bff !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    font-size: 12px !important; /* Font 12px */
    line-height: 1.3 !important;
}

.document-link:hover {
    text-decoration: underline !important;
}

/* MODAL FOOTER - Close button on the right */
.modal-footer {
    padding: 20px 24px !important;
    border-top: 1px solid #e9ecef !important;
    background: #f8f9fa !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-radius: 0 0 12px 12px !important;
}

.purchase-summary {
    font-weight: 600 !important;
    color: #28a745 !important;
    font-size: 1.1rem !important;
    flex: 1 !important;
}

#close-details-modal {
    background: #6c757d !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    margin-left: auto !important; /* Push to right edge */
}

#close-details-modal:hover {
    background: #5a6268 !important;
    transform: translateY(-1px) !important;
}

/* SUCCESS/ERROR STATES */
.purchase-success {
    text-align: center !important;
    padding: 40px 20px !important;
}

.purchase-success h2 {
    color: #28a745 !important;
    margin-bottom: 20px !important;
}

.success-details {
    background: #f8f9fa !important;
    padding: 20px !important;
    border-radius: 8px !important;
    margin: 20px 0 !important;
    text-align: left !important;
}

.success-details p {
    margin: 8px 0 !important;
    color: #333 !important;
}

.certificate-info {
    background: #e7f3ff !important;
    padding: 20px !important;
    border-radius: 8px !important;
    margin-top: 20px !important;
    border-left: 4px solid #007bff !important;
}

.certificate-info h3 {
    margin-bottom: 10px !important;
    color: #007bff !important;
}

.certificate-info .btn {
    background: #007bff !important;
    color: white !important;
    padding: 10px 20px !important;
    border: none !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    display: inline-block !important;
    margin-top: 10px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
}

.certificate-info .btn:hover {
    background: #0056b3 !important;
    transform: translateY(-1px) !important;
}

.error-message {
    text-align: center !important;
    padding: 40px 20px !important;
    color: #dc3545 !important;
}

.error-message h3 {
    color: #dc3545 !important;
    margin-bottom: 15px !important;
}

/* LOADING STATES */
.loading-spinner {
    text-align: center !important;
    padding: 40px 20px !important;
    color: #6c757d !important;
    font-size: 16px !important;
}

.loading-spinner::after {
    content: '' !important;
    display: inline-block !important;
    width: 20px !important;
    height: 20px !important;
    margin-left: 10px !important;
    border: 2px solid #6c757d !important;
    border-top: 2px solid transparent !important;
    border-radius: 50% !important;
    animation: spin 1s linear infinite !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* KEYBOARD NAVIGATION HINTS */
.keyboard-hint {
    position: absolute !important;
    bottom: 20px !important;
    right: 20px !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    opacity: 0.8 !important;
    pointer-events: none !important;
    z-index: 10002 !important;
}

/* Stripe Payment Form Styles */
.stripe-payment-form {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.purchase-summary-large {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.purchase-summary-large p {
    margin: 5px 0;
    color: #333;
}

.payment-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.payment-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.payment-tab.active {
    border-bottom-color: #28a745;
    color: #28a745;
}

.payment-tab.disabled {
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.payment-content {
    position: relative;
}

.payment-method {
    display: none;
}

.payment-method.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}

#card-element {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
}

#card-errors {
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
}

.payment-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.payment-actions button {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.payment-actions .btn-primary {
    background: #28a745;
    color: white;
}

.payment-actions .btn-primary:hover:not(:disabled) {
    background: #218838;
}

.payment-actions .btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.payment-actions .btn-secondary {
    background: #6c757d;
    color: white;
}

.payment-actions .btn-secondary:hover {
    background: #5a6268;
}

.coming-soon {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.coming-soon h4 {
    margin-bottom: 10px;
    color: #495057;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .modal-container {
        padding: 10px !important;
        align-items: flex-start !important;
        padding-top: 20px !important;
    }
    
    .territory-details-modal {
        max-height: 95vh !important;
        width: 100% !important;
    }
    
    /* КОМПАКТНАЯ НАВИГАЦИЯ - одна строка 20px */
    .territory-navigation {
        display: grid !important;
        grid-template-columns: 1fr 2fr 1fr !important;
        gap: 2px !important;
        padding: 1px !important;
        margin-bottom: 5px !important;
        height: 20px !important;
        align-items: center !important;
        background: rgba(40, 167, 69, 0.1) !important;
        border-radius: 4px !important;
        border: 1px solid rgba(40, 167, 69, 0.2) !important;
    }
    
    .nav-btn {
        width: 100% !important;
        min-width: unset !important;
        padding: 1px 2px !important;
        font-size: 10px !important;
        height: 18px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
        background: #28a745 !important;
        color: white !important;
        border: none !important;
        border-radius: 3px !important;
        font-weight: 500 !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    .nav-btn:hover:not(:disabled) {
        background: #218838 !important;
    }
    
    .nav-btn:disabled {
        background: #6c757d !important;
        color: #adb5bd !important;
        cursor: not-allowed !important;
        opacity: 0.6 !important;
    }
    
    .nav-btn svg {
        width: 8px !important;
        height: 8px !important;
        fill: currentColor !important;
    }
    
    .territory-counter {
        padding: 1px 2px !important;
        font-size: 10px !important;
        height: 18px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        font-weight: 600 !important;
        color: #28a745 !important;
        background: white !important;
        border-radius: 3px !important;
        border: 1px solid rgba(40, 167, 69, 0.3) !important;
    }
    
    /* УБИРАЕМ ФИКСИРОВАННЫЕ ПОЗИЦИИ У ЗАГОЛОВКА И ОПЛАТЫ */
    .modal-header {
        position: static !important;
        padding: 10px 15px !important;
        background: white !important;
        border-bottom: 1px solid #e9ecef !important;
    }
    
    .header-title-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        min-height: auto !important;
    }
    
    .modal-header h2 {
        height: auto !important;
        text-align: center !important;
        margin-bottom: 0 !important;
        font-size: 14px !important;
    }
    
    /* УБИРАЕМ ЛЮБОЕ ФИКСИРОВАННОЕ ПОЗИЦИОНИРОВАНИЕ У ОПЛАТЫ */
    .header-actions,
    .purchase-controls {
        position: static !important;
        transform: none !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        z-index: auto !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
    }
    
    .header-actions {
        flex-direction: column !important;
        width: 100% !important;
        height: auto !important;
        gap: 10px !important;
    }
    
    .purchase-controls {
        flex-direction: column !important;
        width: 100% !important;
        height: auto !important;
        gap: 8px !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* УБИРАЕМ ПОЗИЦИОНИРОВАНИЕ У ВСЕХ ДОЧЕРНИХ ЭЛЕМЕНТОВ */
    .purchase-controls *,
    .header-actions * {
        position: static !important;
        transform: none !important;
    }
    
    .purchase-controls input,
    #purchaseRetireBtn {
        width: 100% !important;
        min-width: unset !important;
        height: 44px !important;
    }
    
    .close-modal {
        align-self: flex-end !important;
        margin-top: -40px !important;
        position: relative !important;
        z-index: 10 !important;
    }
    
    /* Mobile Content */
    .territory-details-tabs {
        padding: 0 15px !important;
        overflow-x: auto !important;
    }
    
    .tab-content {
        padding: 15px !important;
    }
    
    .details-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    
    .validation-info {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }
    
    .detail-item,
    .validation-item {
        padding: 6px !important;
    }
    
    .detail-label,
    .detail-value,
    .validation-label,
    .validation-value {
        font-size: 11px !important;
    }
    
    #territory-map-container {
        height: 150px !important;
    }
    
    /* FOOTER ОСТАЕТСЯ ЗАКРЕПЛЕННЫМ */
    .modal-footer {
        position: sticky !important;
        bottom: 0 !important;
        flex-direction: row !important;
        gap: 15px !important;
        align-items: center !important;
        padding: 15px !important;
        background: #f8f9fa !important;
        border-top: 1px solid #e9ecef !important;
        z-index: 1000 !important;
    }
    
    .purchase-summary {
        text-align: left !important;
        flex: 1 !important;
    }
    
    #close-details-modal {
        margin-left: auto !important;
        flex-shrink: 0 !important;
    }
}

@media (max-width: 480px) {
    .modal-container {
        padding: 5px !important;
        padding-top: 10px !important;
    }
    
    .territory-details-modal {
        max-height: 98vh !important;
    }
    
    /* Навигация остается компактной */
    .territory-navigation {
        padding: 1px !important;
        gap: 1px !important;
        height: 20px !important;
    }
    
    .nav-btn {
        padding: 1px !important;
        font-size: 9px !important;
        height: 18px !important;
        gap: 1px !important;
    }
    
    .nav-btn svg {
        width: 6px !important;
        height: 6px !important;
    }
    
    .territory-counter {
        padding: 1px !important;
        font-size: 9px !important;
        height: 18px !important;
    }
    
    /* Заголовок и оплата остаются статичными */
    .modal-header,
    .header-actions,
    .purchase-controls {
        position: static !important;
        transform: none !important;
    }
    
    .modal-header h2 {
        font-size: 14px !important;
        line-height: 1.3 !important;
    }
    
    .purchase-controls input,
    #purchaseRetireBtn {
        height: 48px !important;
        font-size: 16px !important;
    }
    
    .modal-header,
    .tab-content,
    .modal-footer {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .details-grid {
        grid-template-columns: 1fr !important;
        gap: 5px !important;
    }
    
    .detail-item,
    .validation-item {
        padding: 5px !important;
    }
    
    .detail-label,
    .detail-value,
    .validation-label,
    .validation-value {
        font-size: 10px !important;
    }
    
    #territory-map-container {
        height: 120px !important;
    }
    
    .modal-footer {
        padding: 15px !important;
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    
    .purchase-summary {
        text-align: center !important;
        order: 1 !important;
    }
    
    #close-details-modal {
        order: 2 !important;
        margin-left: 0 !important;
        align-self: flex-end !important;
        width: auto !important;
        max-width: 120px !important;
    }
}

/* Updated buy-modal.css */

/* Purchase section in content */
.purchase-section {
    position: static !important;
    background: #f8f9fa !important;
    border: 2px solid #28a745 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    margin-bottom: 20px !important;
}

.purchase-section input,
.purchase-section button {
    width: 100% !important;
    padding: 12px !important;
    border-radius: 6px !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
}

/* FIXED FOOTER */
.modal-footer {
    position: sticky !important;
    bottom: 0 !important;
    background: #f8f9fa !important;
    border-top: 1px solid #e9ecef !important;
    padding: 15px 24px !important;
    z-index: 1001 !important;
    margin-top: auto !important; /* Push to bottom */
}

/* Modal structure fix */
.territory-details-modal {
    display: flex !important;
    flex-direction: column !important;
    height: 90vh !important; /* Fixed height */
}

.modal-body {
    flex: 1 !important;
    overflow-y: auto !important;
    margin-bottom: 0 !important; /* Remove bottom margin */
}

/* Mobile fixes */
@media (max-width: 768px) {
    .purchase-section {
        margin: 10px 0 !important;
        padding: 12px !important;
    }
    
    .modal-footer {
        position: sticky !important;
        bottom: 0 !important;
        z-index: 1001 !important;
    }
    
    .territory-details-modal {
        height: 95vh !important;
    }
}

/* Mobile only buy-modal.css */

/* Hide desktop controls*/
@media (max-width: 768px) {
    .header-actions.mobile-hidden {
        display: none !important;
    }
    
    .mobile-purchase-section {
        position: static !important;
        background: #f8f9fa !important;
        border: 2px solid #28a745 !important;
        border-radius: 8px !important;
        padding: 15px !important;
        margin-bottom: 20px !important;
    }
    
    .mobile-purchase-section input,
    .mobile-purchase-section button {
        width: 100% !important;
        padding: 12px !important;
        border-radius: 6px !important;
        font-size: 16px !important;
        box-sizing: border-box !important;
    }
}


@media (min-width: 769px) {
    .mobile-purchase-section {
        display: none !important;
    }
}
