/* ============================================
   ROOT & BASE STYLES (Переменные и сброс)
   ============================================ */
:root {
    /* Основные цвета - строгая деловая палитра */
    --primary-color: #1A2B4C;
    /* Глубокий синий для текста и акцентов */
    --primary-light: #2A3C5E;
    --primary-dark: #0F1A2E;
    --secondary-color: #4A5B7A;
    --accent-color: #2E7D32;
    /* Приглушенный зеленый для успеха */
    --accent-light: #4CAF50;
    --accent-dark: #1B5E20;

    /* Системные цвета */
    --bg-light: #F8FAFC;
    /* Очень светлый фон */
    --bg-white: #FFFFFF;
    --border-color: #E2E8F0;
    /* Спокойный серый для границ */

    /* Текст */
    --text-primary: #1A2B4C;
    --text-secondary: #4A5B7A;
    --text-muted: #64748B;

    /* Статусные цвета - приглушенные, вписывающиеся в палитру */
    --error-color: #B91C1C;
    /* Темно-красный, не кричащий */
    --error-bg: #FEF2F2;
    /* Очень светлый красный фон */
    --error-border: #FEE2E2;
    --warning-color: #92400E;
    /* Приглушенный оранжевый */
    --warning-bg: #FFFBEB;
    --warning-border: #FEF3C7;
    --success-color: #065F46;
    /* Темно-зеленый */
    --success-bg: #ECFDF5;
    --success-border: #D1FAE5;

    /* Тени */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.01);

    /* Скругления */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Анимации */
    --transition: all 0.15s ease;

    /* Брейкпоинты */
    --breakpoint-sm: 480px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1400px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-light);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.container {
    max-width: var(--breakpoint-xl);
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   TYPOGRAPHY (Заголовки, текст)
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 16px;
}

h4 {
    font-size: 15px;
}

/* ============================================
   FOCUS STATES (Доступность)
   ============================================ */
:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ============================================
   HEADER & STATS (Шапка и счетчики)
   ============================================ */
.header {
    background: var(--bg-white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin: 20px 0;
    border: 1px solid var(--border-color);
}

.header h1 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 28px;
    text-align: center;
    letter-spacing: -0.3px;
}

.header-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    background: var(--bg-light);
    padding: 12px 20px;
    border-radius: 40px;
    border: 1px solid var(--border-color);
    word-break: break-word;
}

.stat {
    white-space: normal;
    font-weight: 500;
    word-break: break-word;
}

.stat-sep {
    color: var(--border-color);
}

/* Disclaimer Grid */
.disclaimer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0 0;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    padding: 20px;
}

.disclaimer-grid-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.disclaimer-grid-icon {
    font-size: 24px;
    background: var(--bg-white);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    color: var(--primary-color);
}

.disclaimer-grid-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 15px;
}

.disclaimer-grid-item p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================
   DOCUMENT TABS (Вкладки)
   ============================================ */
.document-tabs-container {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.tabs-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    min-height: 64px;
    background: var(--bg-white);
    flex-wrap: wrap;
}

.tabs-container {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    background: var(--bg-light);
    padding: 4px;
    border-radius: 40px;
    width: calc(50% - 12px);
    min-width: 280px;
}

.tab-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border-radius: 40px;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(26, 43, 76, 0.04);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.tab-btn.active .tab-icon {
    color: white;
}

.tab-icon {
    font-size: 16px;
    transition: var(--transition);
}

.tab-actions {
    margin-left: 20px;
    flex-shrink: 0;
}

.tab-btn .tab-text::before {
    display: none;
}

.sync-button {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    cursor: pointer;
}

.sync-button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.sync-button:hover .sync-icon {
    color: white;
}

.sync-button:active {
    transform: scale(0.98);
}

.sync-icon {
    font-size: 14px;
    transition: var(--transition);
}

/* ============================================
   SYNC DROPDOWN BUTTONS
   ============================================ */
.sync-dropdown {
    position: fixed;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 240px;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.sync-source-btn {
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: var(--bg-white);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    color: var(--text-primary);
}

.sync-source-btn:hover {
    background: var(--primary-color);
    color: white;
}

.sync-source-btn:hover span {
    color: white;
}

.sync-source-btn:first-child {
    border-bottom: 1px solid var(--border-color);
}

.sync-source-btn:active {
    transform: scale(0.98);
}

/* ============================================
   MAIN GRID (Основная сетка)
   ============================================ */
.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 20px 0;
}

/* ============================================
   FORM SECTION (Левая колонка)
   ============================================ */
.form-section {
    background: var(--bg-white);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    border: 1px solid var(--border-color);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-light);
}

.form-section::-webkit-scrollbar {
    width: 6px;
}

.form-section::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 20px;
}

.form-section::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 20px;
}

.form-section-block {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.form-section-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-block h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
    letter-spacing: -0.2px;
}

.section-info {
    background: rgba(46, 125, 50, 0.05);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 13px;
    border-left: 4px solid var(--accent-color);
    color: var(--text-secondary);
    line-height: 1.6;
}

.sync-instruction {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

/* Form elements */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

label.required::after {
    content: " *";
    color: var(--error-color);
    font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 43, 76, 0.1);
}

/* Валидация через :invalid */
input:invalid,
select:invalid,
textarea:invalid {
    border-color: var(--error-color);
}

input:invalid:focus,
select:invalid:focus,
textarea:invalid:focus {
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

.field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: normal;
    line-height: 1.5;
}

.field-suffix {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Conditional fields */
.conditional-field {
    margin-top: 16px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    animation: slideDown 0.2s ease;
}

/* Checkboxes and Radios - исправлено центрирование */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    padding: 8px 0;
    padding-left: 35px;
    position: relative;
    color: var(--text-primary);
    transition: var(--transition);
    border-radius: var(--radius-sm);
    min-height: 36px;
}

.checkbox-label:hover,
.radio-label:hover {
    background-color: var(--bg-light);
}

.checkbox-label input,
.radio-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 0;
    height: 0;
}

.checkmark {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.radiomark {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    transition: var(--transition);
}

.checkbox-label input:checked~.checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input:checked~.checkmark:after {
    content: "";
    display: block;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.radio-label input:checked~.radiomark {
    border-color: var(--primary-color);
}

.radio-label input:checked~.radiomark:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
}

.checkbox-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.option-text-wrapper {
    display: block;
    margin-left: 28px;
    margin-top: -24px;
}

.option-text {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    font-size: 13px;
}

/* Warning messages */
.warning-message {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning-color);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.6;
}

/* Parties grid */
.parties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.party-block {
    padding: 20px;
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.party-block:hover {
    box-shadow: var(--shadow-sm);
}

.party-block h3 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 16px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Form actions - в одну линию */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 24px 0 0;
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
    flex-wrap: wrap;
    flex-direction: row-reverse;
}

.form-actions .btn {
    flex: 1;
    min-width: 140px;
    /* минимальная ширина */
    max-width: 200px;
    /* максимальная ширина */
    white-space: normal;
    /* разрешаем перенос текста */
    padding: 12px 16px;
    word-break: break-word;
    /* переносим длинные слова */
    text-align: center;
    line-height: 1.3;
}

/* ============================================
   BUTTONS (Кнопки)
   ============================================ */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

.btn:disabled.btn-loading-state {
    opacity: 1;
    cursor: wait;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -2px rgba(26, 43, 76, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -4px rgba(26, 43, 76, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.97) translateY(0);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-success {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 6px -2px rgba(46, 125, 50, 0.2);
}

.btn-success:hover:not(:disabled) {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -4px rgba(46, 125, 50, 0.3);
}

.btn-success:active:not(:disabled) {
    transform: scale(0.97) translateY(0);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
}

.btn-outline .loading {
    border: 2px solid rgba(26, 43, 76, 0.3);
    border-top-color: var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.btn-outline:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* Стили для загрузки (loading spinner) */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

.btn-secondary .loading {
    border: 2px solid rgba(26, 43, 76, 0.2);
    border-top-color: var(--primary-color);
}

/* ============================================
   PREVIEW SECTION (Правая колонка)
   ============================================ */
.preview-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.preview-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.preview-header h2 {
    color: var(--primary-color);
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.document-preview {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    background: var(--bg-white);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-light);
}

.document-preview::-webkit-scrollbar {
    width: 6px;
}

.document-preview::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.document-preview::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 20px;
}

.preview-auto-update-info {
    font-size: 12px;
    color: var(--text-muted);
    background: transparent;
    padding: 8px 0;
    margin: 8px 20px 16px;
    text-align: center;
    border-top: 1px dashed var(--border-color);
    border-bottom: 1px dashed var(--border-color);
    display: none;
    width: auto;
    animation: fadeIn 0.3s ease;
    line-height: 1.5;
    letter-spacing: 0.2px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    font-style: normal;
    line-height: 1;
    opacity: 0.9;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    /* защита от сжатия */
}

.preview-auto-update-info .info-icon {
    display: none;
}

.info-text {
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.5;
}

.preview-auto-update-info .info-text {
    color: var(--text-muted);
    font-weight: 600;
    font-style: italic;
}

/* Document content styles */
.document-content {
    font-family: 'Times New Roman', Times, serif;
    line-height: 1.5;
    color: #000;
    max-width: 750px;
    margin: 0 auto;
    font-size: 15px;
}

.document-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 25px;
    border-bottom: 2px solid #000;
}

.document-title {
    font-size: 19px;
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #000;
}

.document-meta {
    font-size: 15px;
    margin: 8px 0;
    color: #333;
}

.document-section {
    margin-bottom: 25px;
    page-break-inside: avoid;
}

.section-title {
    font-weight: bold;
    margin-bottom: 12px;
    font-size: 16px;
    border-bottom: 1px solid #000;
    padding-bottom: 5px;
    color: #000;
}

.section-content {
    font-size: 15px;
    line-height: 1.6;
    text-align: justify;
}

/* Preview error state */
.preview-error-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

.preview-error-icon {
    font-size: 56px;
    margin-bottom: 24px;
    opacity: 0.7;
    color: var(--text-muted);
}

.preview-error-state h3 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 20px;
    font-weight: 600;
}

.preview-error-state p {
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
}

.preview-error-count {
    background: var(--bg-light);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    display: inline-block;
    border: 1px solid var(--border-color);
    font-weight: 500;
    color: var(--text-primary);
}

.preview-error-count strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Preview welcome state */
.preview-welcome {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.welcome-icon {
    font-size: 56px;
    margin-bottom: 24px;
    opacity: 0.8;
}

.preview-welcome h3 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 20px;
    font-weight: 600;
}

.preview-welcome p {
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
}

.progress-info {
    background: rgba(26, 43, 76, 0.05);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin: 30px 0;
    border-left: 4px solid var(--primary-color);
    font-size: 14px;
}

.welcome-tips {
    text-align: left;
    background: var(--bg-light);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin: 0 auto;
}

.welcome-tips h4 {
    color: var(--primary-color);
    margin-bottom: 16px;
    font-size: 16px;
    text-align: center;
}

.welcome-tips ul {
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.welcome-tips li {
    margin-bottom: 8px;
}

/* ============================================
   ACCORDION (Аккордеон для стандартных пунктов)
   ============================================ */
.standard-items-accordion {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-light);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    list-style: none;
}

.accordion-header::-webkit-details-marker {
    display: none;
}

.accordion-header:hover {
    background: #E9EEF3;
}

.accordion-icon {
    margin-right: 12px;
    font-size: 18px;
    color: var(--primary-color);
}

.accordion-title {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.accordion-toggle {
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 500;
    background: rgba(26, 43, 76, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
}

.accordion-content {
    padding: 24px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
}

.included-items-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.obligations-column h5,
.rights-column h5 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border-color);
}

.included-items-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
}

.included-items-list li {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.accordion-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    font-style: italic;
}

/* ============================================
   MODAL (Модальное окно)
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background-color: var(--bg-white);
    margin: 5% auto;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-body {
    padding: 28px 24px;
}

.download-option {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.download-option:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.download-option h4 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 16px;
}

.download-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ============================================
   COOKIE BANNER
   ============================================ */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cookie-content {
    max-width: var(--breakpoint-xl);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-text {
    flex: 1;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    font-size: 13px;
}

.cookie-text a {
    color: #FFD966;
    text-decoration: underline;
    transition: var(--transition);
}

.cookie-text a:hover {
    opacity: 0.8;
}

.cookie-warning {
    margin-top: 4px;
    font-size: 12px;
    color: #FFD966;
}

.btn-cookie {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--transition);
    font-size: 13px;
    min-height: 36px;
}

.btn-cookie:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-cookie:active {
    transform: scale(0.97);
}

/* ============================================
   FOOTER (Подвал)
   ============================================ */
.footer {
    text-align: center;
    padding: 32px 20px;
    margin-top: 40px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}

.footer-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-bottom: 24px;
}

.footer-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: var(--transition);
}

.footer-nav a:hover {
    color: var(--primary-color);
}

.footer-nav .sep {
    color: var(--border-color);
    display: none;
}

.footer-copyright {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.footer-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.footer-note.small {
    font-size: 11px;
    margin-top: 5px;
}

.footer-note a {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid var(--accent-color);
    padding-bottom: 1px;
    transition: var(--transition);
}

.footer-note a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--primary-color);
}

/* ============================================
   LEGAL PAGES (Юридические страницы)
   ============================================ */
.legal-page {
    max-width: 800px;
    margin: 40px auto;
    padding: 40px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);

    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.legal-page h1 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 28px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 15px;
}

.legal-page h2 {
    color: var(--primary-color);
    margin: 32px 0 16px;
    font-size: 20px;
}

.legal-page p,
.legal-page li {
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.legal-page a {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid var(--accent-color);
    padding-bottom: 1px;
    transition: var(--transition);
}

.legal-page a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--primary-color);
}

.legal-date {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 30px;
    font-size: 14px;
}

.legal-footer {
    margin-top: auto;
    /* margin-top: 40px; */
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.legal-footer a {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid var(--accent-color);
    padding-bottom: 1px;
    transition: var(--transition);
}

.legal-footer a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--primary-color);
}

.important-notice {
    background: var(--bg-light);
    border-left: 4px solid var(--primary-color);
    padding: 16px;
    margin: 20px 0;
    border-radius: var(--radius-md);
}

.notice-title {
    margin: 0;
    font-weight: 600;
    color: var(--warning-color);
}

.notice-subtitle {
    margin: 8px 0 0 0;
}


/* ============================================
   ERROR PAGES (404, etc)
   ============================================ */
.error-page {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.error-content {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.error-icon {
    font-size: 64px;
    margin-bottom: 24px;
    line-height: 1;
}

.error-content h2 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.error-text {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 28px;
}

.error-actions .btn {
    min-width: 200px;
    padding: 12px 30px;
    font-size: 15px;
}

/* ============================================
   ALERTS & NOTIFICATIONS - исправленные отступы
   ============================================ */
.generation-error-alert,
.download-error-alert,
.download-success-alert,
.sync-notification {
    position: fixed;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    max-width: 400px;
    width: 90%;
    overflow: hidden;
    animation: slideInRight 0.3s ease;
}

.generation-error-alert,
.download-error-alert,
.sync-notification {
    top: 20px;
    right: 20px;
}

.download-success-alert {
    bottom: 20px;
    right: 20px;
    animation: slideInUp 0.3s ease;
}

/* Цвета для разных типов */
.generation-error-alert,
.download-error-alert {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
}

.download-success-alert {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}

.sync-notification {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}

/* Единая структура содержимого */
.alert-content {
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

.alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* Для ошибок */
.generation-error-alert .alert-icon,
.download-error-alert .alert-icon {
    background: var(--error-color);
    color: white;
}

.generation-error-alert .alert-icon::after,
.download-error-alert .alert-icon::after {
    content: "!";
}

/* Для успеха */
.download-success-alert .alert-icon {
    background: var(--success-color);
    color: white;
    font-size: 16px;
}

.download-success-alert .alert-icon::after {
    content: "✓";
}

.alert-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.alert-text strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.alert-text p {
    margin: 0;
    color: var(--text-secondary);
}

/* Цвета заголовков */
.generation-error-alert .alert-text strong,
.download-error-alert .alert-text strong {
    color: var(--error-color);
}

.download-success-alert .alert-text strong {
    color: var(--success-color);
}

.sync-notification-error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
}

.sync-notification-error .alert-icon {
    background: var(--error-color);
    color: white;
}

.sync-notification-error .alert-icon::after {
    content: "!";
}

.sync-notification-error .alert-text strong {
    color: var(--error-color);
}

.sync-notification-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}

.sync-notification-success .alert-icon {
    background: var(--success-color);
    color: white;
    font-size: 16px;
}

/* Иконки через CSS-псевдоэлементы */
.sync-notification-success .alert-icon::after {
    content: "✓";
}

/* Цвета заголовков */
.sync-notification-success .alert-text strong {
    color: var(--success-color);
}

/* Единый крестик */
.alert-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: currentColor;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    opacity: 0.5;
    flex-shrink: 0;
    margin: -4px -4px 0 0;
}

.alert-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

/* ============================================
   CONFIRM DIALOG - в стиле проекта
   ============================================ */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.confirm-overlay.active {
    opacity: 1;
}

.confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    min-width: 400px;
    max-width: 450px;
    width: 90%;
    opacity: 0;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.confirm-dialog.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.confirm-content {
    padding: 24px;
}

.confirm-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-light);
}

.confirm-icon {
    font-size: 20px;
    color: var(--warning-color);
    opacity: 0.9;
}

.confirm-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.confirm-body {
    padding: 24px;
}

.confirm-body p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.confirm-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-white);
    flex-direction: row-reverse;
}

.confirm-footer .btn {
    min-width: 100px;
    padding: 10px 20px;
}

.confirm-footer .btn-primary {
    background: var(--primary-color);
}

.confirm-footer .btn-primary:hover {
    background: var(--primary-light);
}

/* Адаптивность */
@media (max-width: 768px) {

    .sync-instruction {
        font-size: 12px;
    }

    .confirm-dialog {
        width: 95%;
        min-width: auto;
    }

    .confirm-content {
        padding: 20px;
    }

    .confirm-footer {
        flex-direction: column-reverse;
    }

    .confirm-footer .btn {
        width: 100%;
    }
}

/* ============================================
   ERROR STATES
   ============================================ */
.field-with-error {
    border-color: var(--error-color) !important;
    background-color: var(--error-bg) !important;
}

input.field-with-error,
select.field-with-error,
textarea.field-with-error {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1) !important;
}

.validation-error-message {
    margin-top: 8px;
    animation: slideDown 0.2s ease;
}

.validation-error-message .warning-message {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-color);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* Error list */
.error-list {
    margin: 0 0 20px 0;
    animation: slideDown 0.2s ease;
}

.error-list-container {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.error-list-header {
    background: var(--border-color);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.error-list-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.error-progress {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.error-items {
    padding: 12px;
    background: var(--bg-white);
}

.error-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    animation: fadeIn 0.2s ease;
}

.error-item:last-child {
    border-bottom: none;
}

.error-number {
    background: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.error-message {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.error-scroll-btn {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    margin-left: 12px;
    transition: var(--transition);
    white-space: nowrap;
}

.error-scroll-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.error-scroll-btn:active {
    transform: scale(0.97);
}

/* Error header */
.error-header {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    animation: slideDown 0.2s ease;
}

.error-header-content {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
}

.error-header-icon {
    font-size: 24px;
    opacity: 0.8;
}

.error-header-text {
    flex: 1;
}

.error-header-text strong {
    color: var(--error-color);
    font-size: 15px;
    font-weight: 600;
}

.error-header-subtitle {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.error-progress-badge {
    display: none;
    background: var(--error-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
}

/* ============================================
   CHARACTER COUNTER
   ============================================ */
.character-counter {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
    transition: var(--transition);
}

.character-counter.warning {
    color: var(--warning-color);
}

.character-counter.error {
    color: var(--error-color);
}

.field-over-limit {
    border-color: var(--error-color) !important;
}

/* ============================================
   MOBILE STYLES
   ============================================ */
.mobile-preview-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    padding: 14px 24px;
    border-radius: 40px;
    border: none;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition);
    min-height: 48px;
    min-width: 48px;
}

.mobile-preview-btn:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26, 43, 76, 0.3);
}

.mobile-preview-btn:active {
    transform: scale(0.97);
}

.preview-section.mobile-expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    background: var(--bg-white);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    display: none;
    border-radius: 0;
    height: 100vh;
    /* вся высота экрана */
    overflow-y: auto;
    /* ВКЛЮЧАЕМ СКРОЛЛ */
    -webkit-overflow-scrolling: touch;
    /* плавный скролл на iOS */
}

.preview-section.mobile-expanded.active {
    transform: translateY(0);
    display: block;
}

/* Заголовок мобильного предпросмотра */
.preview-section.mobile-expanded .preview-header {
    position: sticky;
    /* прилипает при скролле */
    top: 0;
    z-index: 10;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
}

/* Контент мобильного предпросмотра */
.preview-section.mobile-expanded .document-preview {
    height: auto;
    /* не фиксированная высота */
    min-height: calc(100vh - 80px);
    /* минимальная высота */
    overflow-y: visible;
    /* скролл на родителе */
    padding: 20px;
    padding-bottom: 40px;
    /* доп. место внизу */
}

.close-preview {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-preview:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.close-preview:active {
    transform: scale(0.95);
}

.close-preview:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.scroll-to-top-btn {
    display: none;
    /* По умолчанию скрыта */
}

/* ============================================
   MEDIA QUERIES
   ============================================ */
@media (max-width: 1024px) {
    .app-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .form-section {
        max-height: none;
    }

    .preview-section {
        height: auto;
        max-height: 600px;
    }

    .form-actions .btn {
        min-width: 120px;
        padding: 12px 12px;
        font-size: 13px;
    }

    .scroll-to-top-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary-color);
        color: white;
        border: none;
        font-size: 22px;
        box-shadow: var(--shadow-lg);
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
        z-index: 999;
        cursor: pointer;
    }

    .scroll-to-top-btn.visible {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0px 9px 40px 18px;
    }

    .header {
        padding: 20px;
    }

    .header h1 {
        font-size: 24px;
    }

    .header-stats {
        width: 100%;
        flex-direction: column;
        gap: 8px;
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .stat-sep {
        display: none;
    }

    .disclaimer-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .disclaimer-grid-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .tabs-wrapper {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .tabs-container {
        width: 100%;
        border-radius: var(--radius-md);
        padding: 4px;
        min-width: auto;
    }

    .tab-btn {
        padding: 12px 8px;
        font-size: 13px;
        min-height: 48px;
    }

    .tab-text {
        font-size: 12px;
    }

    .tab-actions {
        width: 100%;
        margin-left: 0;
    }

    .sync-button {
        width: 100%;
        justify-content: center;
        /* min-height: 48px; */
    }

    .form-section {
        padding: 20px;
    }

    .parties-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .form-actions .btn {
        width: 100%;
        max-width: none;
        min-width: 0;
        white-space: normal;
        padding: 14px 16px;
        /* чуть больше для touch */
        font-size: 14px;
    }

    .generation-error-alert,
    .download-error-alert,
    .download-success-alert,
    .sync-notification {
        max-width: 90%;
        left: 5%;
        right: 5%;
    }

    .generation-error-alert,
    .download-error-alert,
    .sync-notification {
        top: 10px;
    }

    .download-success-alert {
        bottom: 10px;
    }

    .alert-icon {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }

    .alert-content {
        padding: 14px 16px;
        gap: 10px;
    }

    .mobile-preview-btn {
        display: block;
        min-height: 48px;
        min-width: 48px;
    }

    .preview-section:not(.mobile-expanded) {
        display: none;
    }

    .preview-auto-update-info {
        font-size: 11px;
        padding: 6px 0;
        margin: 8px 15px 12px;
    }

    .info-icon {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }

    .included-items-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .accordion-header {
        padding: 14px;
        flex-wrap: wrap;
    }

    .accordion-title {
        width: 100%;
        margin-bottom: 6px;
    }

    .accordion-content {
        padding: 18px;
    }

    .download-buttons {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }

    .cookie-content {
        flex-direction: column;
        text-align: center;
    }

    .btn-cookie {
        width: 100%;
        min-height: 44px;
    }

    .footer-nav {
        flex-direction: column;
        gap: 8px;
    }

    .footer-nav a {
        display: block;
        padding: 8px 0;
        /* min-height: 44px; */
    }
}

@media (max-width: 480px) {
    .document-title {
        font-size: 16px;
    }

    .document-meta {
        font-size: 13px;
    }

    .document-content .section-title {
        font-size: 14px;
    }

    .section-content {
        font-size: 13px;
    }

    .document-header {
        margin-bottom: 25px;
        padding-bottom: 15px;
    }

    .header-stats {
        padding: 12px;
        font-size: 12px;
        gap: 6px;
    }

    .stat {
        line-height: 1.4;
    }

    .stat:first-child {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .form-actions .btn {
        padding: 12px 12px;
        font-size: 13px;
    }

    .preview-section.mobile-expanded .preview-header {
        padding: 12px 16px;
    }

    .preview-section.mobile-expanded .document-preview {
        padding: 16px;
        padding-bottom: 30px;
    }

    .close-preview {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .error-page {
        padding: 20px 15px;
    }

    .error-content {
        padding: 30px 20px;
    }

    .error-icon {
        font-size: 48px;
    }

    .error-content h2 {
        font-size: 20px;
    }

    .tabs-container {
        justify-content: space-around;
    }

    .tab-btn {
        padding: 8px 14px;
        flex-direction: column;
        gap: 2px;
    }

    .tab-icon {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .tab-text {
        font-size: 10px;
        line-height: 1.2;
        max-width: 100%;
        word-break: break-word;
    }

    .tab-btn .tab-text {
        font-size: 0;
        /* скрываем оригинальный текст */
    }

    .tab-btn .tab-text::before {
        display: block;
        font-size: 10px;
    }

    /* Сокращаем текст */
    .tab-btn[data-tab="contract"] .tab-text::before {
        content: "Договор";
    }

    .tab-btn[data-tab="acceptance-act"] .tab-text::before {
        content: "Передача";
    }

    .tab-btn[data-tab="return-act"] .tab-text::before {
        content: "Возврат";
    }

    /* Кнопка предпросмотра */
    .mobile-preview-btn {
        bottom: 15px;
        right: 15px;
        padding: 8px 16px;
        font-size: 13px;
        min-height: 40px;
        min-width: 40px;
    }

    /* Кнопка скролла */
    .scroll-to-top-btn {
        bottom: 70px;
        right: 15px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

/* При 360px - еще сильнее сжимаем */
@media (max-width: 360px) {

    .header-stats {
        padding: 10px 8px;
        font-size: 11px;
    }

    .stat span {
        display: block;
        /* каждое число с новой строки */
    }

    .tabs-container {
        gap: 2px;
        padding: 2px;
    }

    .tab-btn {
        padding: 6px 10px;
    }

    .tab-icon {
        font-size: 16px;
    }

    .tab-text {
        font-size: 9px;
    }

    .mobile-preview-btn {
        bottom: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 12px;
        min-height: 35px
    }

    /* Кнопка скролла */
    .scroll-to-top-btn {
        bottom: 60px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .no-print {
        display: none !important;
    }

    .document-preview {
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
    }

    .document-content {
        font-size: 12pt !important;
        line-height: 1.4 !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        color: black !important;
        font-family: 'Times New Roman', Times, serif !important;
    }

    .document-title {
        font-size: 14pt !important;
    }

    .document-meta {
        font-size: 11pt !important;
    }

    .document-content .section-title {
        font-size: 12pt !important;
    }

    .section-content {
        font-size: 11pt !important;
    }

    .document-section {
        page-break-inside: avoid !important;
    }

    input,
    select,
    textarea,
    button,
    .form-section,
    .form-actions,
    .btn,
    .preview-header,
    .document-tabs {
        display: none !important;
    }

    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.hidden {
    display: none !important;
}

.btn-timer-active {
    background: var(--text-muted) !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
    position: relative;
    overflow: hidden;
}

.btn-timer-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 1.5s infinite;
}

/* SEO Content */
.seo-content {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    border: 0;
    clip: rect(0 0 0 0);
}


/* Вроде ОК */

/* СТАРТ */

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.header-logo {
    display: flex;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-text {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header-badge {
    display: flex;
    flex-direction: column;
    margin-left: 13px;
}

.badge-free {
    padding: 0;
    margin: 0;
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .free-badge {
        align-self: flex-start;
    }
}

@media (max-width: 360px) {
    .logo-text {
        font-size: 18px;
    }

    .header-badge {
        padding-top: 5px;
    }

    .badge-free {
        font-size: 12px;
    }

    .disclaimer-grid {
        padding: 2px;
    }
}

/* ============================================
   MOBILE TAP HIGHLIGHT (Убираем голубой прямоугольник)
   ============================================ */
a,
button,
input,
textarea,
select,
label,
[role="button"],
.btn,
.tab-btn,
.checkbox-label,
.radio-label {
    -webkit-tap-highlight-color: transparent;
}

.btn,
.tab-btn,
.checkbox-label,
.radio-label,
.stat,
.header-stats,
.disclaimer-grid-item strong,
.modal-close,
.close-preview,
.mobile-preview-btn,
.scroll-to-top-btn,
.sync-button,
.sync-source-btn,
.error-scroll-btn,
.alert-close,
.accordion-header {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Но ВАЖНО: для input и textarea оставляем возможность выделения */
input,
textarea,
[contenteditable="true"] {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}