* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Times New Roman', Times, serif;
    background-color: #f5f5f5;
    padding: 20px;
    line-height: 1.6;
    color: #000;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.title-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.main-title {
    text-align: center;
    margin: 0;
    font-size: 24px;
    color: #333;
}

.subtitle {
    text-align: center;
    margin: 10px 0 0 0;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

.title-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-toggle,
.btn-highlight,
.btn-clear {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: normal;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-toggle {
    border: 1px solid #28a745;
    background-color: white;
    color: #28a745;
}

.btn-toggle:hover {
    background-color: #28a745;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-toggle:active {
    transform: translateY(0);
}

.legal-field {
    display: inline-block;
}

.btn-highlight {
    border: 1px solid #ffc107;
    background-color: white;
    color: #ffc107;
}

.btn-highlight:hover {
    background-color: #ffc107;
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-highlight.active {
    background-color: #ffc107;
    color: #000;
}

.btn-clear {
    border: 1px solid #dc3545;
    background-color: white;
    color: #dc3545;
}

.btn-clear:hover {
    background-color: #dc3545;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-highlight:active,
.btn-clear:active {
    transform: translateY(0);
}

/* Подсветка полей */
input.highlighted {
    background-color: #fffacd !important;
}

.page {
    background: white;
    width: 210mm;
    min-height: 297mm;
    padding: 8mm 15mm 10mm 15mm;
    margin: 0 auto 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
    page-break-after: always;
    overflow: visible;
}

.pdf-footer {
    position: absolute;
    bottom: 8mm;
    right: 10mm;
    font-size: 7pt;
    color: #808080;
    font-family: Arial, sans-serif;
    z-index: 1000;
}

.page2 {
    margin-top: 20px;
}

.document {
    width: 100%;
    height: 100%;
}

.document h2 {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
    margin-top: 3px;
}

.document h3 {
    font-size: 14px;
    font-weight: bold;
    margin-top: 8px;
    margin-bottom: 5px;
}

.header-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
    font-size: 12px;
    width: 100%;
    flex-wrap: nowrap;
}

.header-line > span {
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
}

.header-line > span:first-child {
    flex-shrink: 0;
}

.header-line > span:last-child {
    flex-shrink: 0;
    margin-left: auto;
}

.date-inputs {
    white-space: nowrap;
}

input[type="text"] {
    border: none;
    background: transparent;
    outline: none;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12px;
    padding: 0 4px;
    min-width: 80px;
    display: inline-block;
    width: auto;
    vertical-align: middle;
    line-height: 1.4;
    margin: 0;
}

.header-line input[type="text"] {
    vertical-align: middle;
    display: inline;
}

.contract-text input[type="text"] {
    vertical-align: middle;
    line-height: 1.4;
}

input[type="text"]::placeholder {
    color: #000;
    opacity: 1;
}

input[type="text"]:focus::placeholder {
    opacity: 0.5;
}

/* Динамические поля - подстраиваются под содержимое */
input[type="text"]:not(.small-input):not(.medium-input):not(.year-input) {
    min-width: 80px;
    width: auto;
    max-width: 100%;
}

/* Для полей с данными делаем их размером по содержимому */
input[type="text"].has-value {
    width: auto;
    min-width: max-content;
}

.full-input {
    width: auto;
    min-width: 250px;
    max-width: 100%;
}

.receipt-line {
    width: 100%;
    min-width: 500px;
}

.medium-input {
    width: 120px;
    min-width: 100px;
}

.small-input {
    width: 30px;
    text-align: center;
}

.medium-input {
    width: 100px;
}

.year-input {
    width: 50px;
    text-align: center;
}

.contract-text {
    font-size: 12px;
    text-align: justify;
    margin-bottom: 8px;
    line-height: 1.3;
}

.contract-text.contract-legal,
.contract-text.contract-individual {
    margin-bottom: 6px;
    line-height: 1.25;
}

.signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    margin-bottom: 15px;
}

.signature-block {
    width: 48%;
    font-size: 12px;
}

.signature-block strong {
    display: block;
    margin-bottom: 10px;
}

.separator {
    border-top: 1px solid #000;
    margin: 12px 0;
    padding-top: 10px;
}

.act-signatures {
    margin-top: 12px;
    margin-bottom: 12px;
}

.receipt-signature {
    margin-top: 40px;
}

.receipt-line {
    width: 100%;
    margin-top: 10px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 40px 0;
    padding: 0 20px;
}

.btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-pdf {
    background-color: #dc3545;
    color: white;
}

.btn-pdf:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn-doc {
    background-color: #007bff;
    color: white;
}

.btn-doc:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.save-status {
    text-align: center;
    padding: 10px;
    font-size: 14px;
    color: #28a745;
    min-height: 30px;
    transition: opacity 0.3s ease;
}

.save-status.show {
    opacity: 1;
}

.save-status.hide {
    opacity: 0;
}

/* Адаптивность для мобильных устройств */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .page {
        width: 100%;
        min-height: auto;
        padding: 8mm 15mm;
        margin-bottom: 15px;
    }
    
    .title-section {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .main-title {
        font-size: 18px;
        margin-bottom: 0;
    }
    
    .subtitle {
        font-size: 11px;
        margin: 8px 15px;
    }
    
    .title-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }
    
    .btn-highlight,
    .btn-clear {
        width: 100%;
        max-width: 100%;
    }
    
    .document h2 {
        font-size: 14px;
    }
    
    .document h3 {
        font-size: 12px;
    }
    
    .contract-text {
        font-size: 11px;
    }
    
    input[type="text"] {
        font-size: 11px;
    }
    
    .full-input {
        width: 100%;
        max-width: 100%;
        min-width: 150px;
        display: block;
        margin: 5px 0;
    }
    
    .receipt-line {
        min-width: 100%;
        width: 100%;
    }
    
    .header-line {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        align-items: baseline;
    }
    
    .header-line > span {
        flex: 1 1 auto;
        min-width: 150px;
        display: inline-flex;
        align-items: baseline;
    }
    
    .header-line > span:last-child {
        margin-left: 0;
    }
    
    .signatures {
        flex-direction: column;
        gap: 20px;
    }
    
    .signature-block {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 15px;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
        padding: 12px 30px;
        font-size: 16px;
    }
}

@media screen and (max-width: 480px) {
    .page {
        padding: 10mm;
    }
    
    .document h2 {
        font-size: 12px;
    }
    
    .contract-text {
        font-size: 10px;
    }
    
    input[type="text"] {
        font-size: 10px;
        min-width: 60px;
    }
    
    .full-input {
        width: 100%;
        min-width: 120px;
    }
    
    .receipt-line {
        min-width: 100%;
        width: 100%;
    }
    
    .btn {
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* Печать */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .title-section {
        display: none;
    }
    
    .main-title {
        display: none;
    }
    
    .title-buttons {
        display: none;
    }
    
    .btn-highlight,
    .btn-clear {
        display: none;
    }
    
    .action-buttons {
        display: none;
    }
    
    .save-status {
        display: none;
    }
    
    .seo-content {
        display: none;
    }
    
    .loading-modal {
        display: none !important;
    }
    
    .page {
        box-shadow: none;
        margin: 0;
        page-break-after: always;
    }
    
    input[type="text"] {
        border: none;
    }
    
    input.highlighted {
        background-color: transparent !important;
    }
}

/* SEO Контент */
.seo-content {
    max-width: 1200px;
    margin: 60px auto 40px;
    padding: 0 20px;
}

.seo-article {
    font-size: 15px;
    line-height: 1.8;
    color: #333;
    text-align: justify;
}

.seo-article h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #000;
    text-align: left;
}

.seo-article p {
    margin-bottom: 20px;
    text-indent: 20px;
}

.seo-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.3s ease;
}

.seo-link:hover {
    color: #0056b3;
    text-decoration: none;
}

/* Модальное окно загрузки */
.loading-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.loading-modal.show {
    display: flex;
}

.loading-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    text-align: center;
}

.ad-banner {
    width: 100%;
    margin: 20px 0;
    min-height: 100px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ad-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.ad-placeholder {
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.loading-bar-container {
    margin: 40px 0;
    position: relative;
}

.loading-bar {
    width: 100%;
    height: 30px;
    background-color: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.loading-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 15px;
    transition: width 0.1s linear;
}

.loading-text {
    margin-top: 15px;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Адаптивность для SEO контента */
@media screen and (max-width: 768px) {
    .seo-content {
        margin: 40px auto 30px;
        padding: 0 15px;
    }
    
    .seo-article {
        font-size: 14px;
    }
    
    .seo-article h2 {
        font-size: 20px;
    }
    
    .title-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }
    
    .btn-highlight,
    .btn-clear {
        width: 100%;
    }
    
    .loading-content {
        padding: 20px;
        width: 95%;
    }
    
    .ad-banner {
        min-height: 80px;
    }
    
    .ad-placeholder {
        font-size: 14px;
    }
}
