body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #1e293b;
}

:root {
    --mobile-gutter: 14px;
    --mobile-card-padding: 18px;
}

header {
    background: linear-gradient(135deg, #10b981, #059669, #22c55e);
    color: white; /* Убедимся, что текст белый */
    padding: 10px 0;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo-link {
    text-decoration: none;
    color: white;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    border: 2px solid white;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.logo:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.logo-text {
    font-weight: bold;
    font-size: 16px;
    color: white;
}

header h1, header h2, header h3, header h4, header h5, header h6, header p, header a {
    color: white; /* Делаем все текстовые элементы в хедере белыми */
}

/* Общий контейнер для SEO-страниц, если он будет использоваться */
.container {
    max-width: 900px;
    margin: 20px auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

main {
    background: rgba(255, 255, 255, 0.95);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 1200px;
    margin: 0 auto;
}

section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

section:last-child {
    border-bottom: none;
}

h1, h2 {
    color: #6366f1;
    font-weight: 600;
}

#upload-section input[type="file"] {
    margin-right: 10px;
}

#analyze-button {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
}

#analyze-button:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Стили для двухколоночного макета договора и анализа */
.two-column-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px; /* Добавлено из SEO-стилей */
    align-items: flex-start; /* Нужно для корректной работы sticky-панели */
}

#contract-view-container, 
.contract-form, /* Для совместимости со старой структурой SEO, если где-то останется */
#analysis-panel-container,
.analysis-results /* Для совместимости */ {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff; /* Изменено на белый */
    min-height: 400px; 
    overflow-y: auto;
}

#analysis-panel-container {
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
}

#contract-text-display {
    min-height: 300px; /* Из SEO-стилей */
    border: 1px solid #ccc; /* Из SEO-стилей */
    padding: 10px 12px; /* Чуть больше воздуха */
    box-sizing: border-box; /* Из SEO-стилей */
    font-family: 'Courier New', Courier, monospace; /* Из SEO-стилей */
    white-space: pre-wrap; /* Из SEO-стилей */
    word-wrap: break-word; /* Из SEO-стилей */
    cursor: pointer; /* Из SEO-стилей */
    line-height: 1.5;
}

/* Стили для отдельных параграфов/сегментов договора */
.contract-paragraph {
    display: block; /* block чтобы каждый пункт был на новой строке */
    padding: 4px 8px;
    border-radius: 3px;
    line-height: 1.5;
    margin: 0 0 4px 0; /* Небольшой отступ между пунктами */
    cursor: pointer;
}

.contract-paragraph + .contract-paragraph {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.contract-paragraph p {
    display: inline;
    margin: 0;
    padding: 0;
}

.contract-paragraph ol,
.contract-paragraph ul {
    display: block; /* block для списков чтобы нумерация работала */
    margin: 4px 0;
    padding-left: 20px; /* Отступ для нумерации */
}

.contract-paragraph ol {
    list-style: decimal; /* Нумерация для ol */
}

.contract-paragraph ul {
    list-style: disc; /* Маркеры для ul */
}

.contract-paragraph:hover {
    background-color: #e6f7ff; /* Подсветка при наведении */
}

/* Стили для панели анализа */
#analysis-results,
.analysis-panel /* Для совместимости */ {
    min-height: 300px; /* Из SEO-стилей */
    /* border: 1px solid #ccc; Убрано, т.к. родитель уже имеет рамку */
    padding: 10px; /* Из SEO-стилей */
    box-sizing: border-box; /* Из SEO-стилей */
    background-color: #fff; /* Из SEO-стилей, чтобы отличался от родителя */
    overflow-y: auto; /* Из SEO-стилей */
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
}

#analysis-results h3,
.analysis-panel h3 {
    color: #7c3aed;
    margin-top: 0;
    font-weight: 600;
    margin-bottom: 6px;
}

#analysis-results p,
.analysis-panel p {
    margin-bottom: 10px; /* Из SEO-стилей */
}

.analysis-summary-banner {
    border: 1px solid #fcd34d;
    background: #fef9c3;
    color: #78350f;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    font-size: 0.95em;
    display: none;
}

.analysis-fallback {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.92em;
}

.analysis-fallback ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.analysis-fallback li {
    margin-bottom: 4px;
}

/* Стили для связанных ключевых слов (из SEO-примера) */
.related-keywords-section {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff; /* Изменено на белый */
}

.related-keywords-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.related-keywords-list li {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    padding: 6px 12px;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
    font-size: 0.9em;
}

/* Стили для основного контента страницы (из SEO-примера) */
.page-content {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff; /* Изменено на белый */
}

/* Стили для выделения рисков (из SEO-примера) */
.analysis-sentence strong { /* Предполагается, что это для выделения рисков */
    color: #d9534f; 
}

footer {
    text-align: center;
    margin-top: 30px;
    color: #666;
    font-size: 0.9em;
}

/* Стили для прогресс-бара (из index.html) */
#analysis-progress {
    margin-top: 10px;
    font-weight: bold;
}
#progress-bar-container {
    width: 100%;
    background-color: #e9e9e9; /* Слегка изменен для контраста, если основной фон белый */
    border-radius: 5px;
    margin-top: 10px;
    display: none; /* Изначально скрыт */
}
#progress-bar {
    width: 0%;
    height: 20px;
    background-color: #4CAF50;
    border-radius: 5px;
    text-align: center;
    line-height: 20px;
    color: white;
}

/* Контракт-анализ: всегда показываем прогресс-бар */
body.contract-analysis-page #progress-bar-container {
    display: block !important;
    border: 1px solid #d1d5db;
}

/* Планшетные стили */
@media (max-width: 1024px) and (min-width: 769px) {
    body {
        padding: 15px;
    }

    .header-container {
        padding: 0 15px;
    }

    main {
        padding: 15px;
    }

    .two-column-layout {
        gap: 15px;
    }

    #contract-view-container, 
    .contract-form,
    #analysis-panel-container,
    .analysis-results {
        padding: 8px;
        font-size: 14px;
    }

    #analysis-panel-container {
        position: static;
        max-height: none;
    }

    #contract-text-display {
        font-size: 13px;
        line-height: 1.3;
    }

    .contract-paragraph {
        font-size: 13px;
        line-height: 1.3;
    }

    #analysis-results,
    .analysis-panel {
        font-size: 13px;
    }

    #analysis-results h3,
    .analysis-panel h3 {
        font-size: 16px;
    }

    #analysis-results p,
    .analysis-panel p {
        font-size: 13px;
    }
}

/* Мобильные стили */
@media (max-width: 768px) {
    body {
        padding: var(--mobile-gutter);
        margin: 0;
        font-size: 16px; /* Принудительно устанавливаем размер шрифта для мобильных */
    }

    header {
        padding: 5px 0; /* Еще больше уменьшаем высоту header */
        margin-bottom: 5px;
    }

    .header-container {
        padding: 0 10px;
        gap: 8px; /* Уменьшаем gap */
        flex-direction: row; /* Возвращаем в строку для экономии места */
        text-align: center;
        align-items: center;
        justify-content: space-between;
    }

    .logo {
        margin-bottom: 0; /* Убираем отступ */
        flex-shrink: 0;
    }

    .logo-text {
        font-size: 11px; /* Уменьшаем размер */
    }

    header h1 {
        font-size: 16px; /* Уменьшаем заголовок */
        margin: 0;
        word-wrap: break-word;
        flex: 1;
        text-align: right;
    }

    main {
        padding: 0 var(--mobile-gutter) calc(var(--mobile-gutter) + 6px);
        margin: 0;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
        border-radius: 12px;
    }

    body.product-default main {
        padding: 0;
        margin: 0;
        background: transparent;
        box-shadow: none;
        border: none;
    }

    .product-default section {
        padding: var(--mobile-card-padding) !important;
        margin: 0 0 calc(var(--mobile-gutter) + 4px);
        border-radius: 18px;
    }

    .product-default .product-hero,
    .product-default .order-form-section {
        padding: calc(var(--mobile-card-padding) + 4px) !important;
    }

    /* Двухколоночный макет на мобиле - переключаемся на одну колонку для лучшего UX */
    .two-column-layout {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }

    #contract-view-container, 
    .contract-form,
    #analysis-panel-container,
    .analysis-results {
        flex: none;
        padding: 10px;
        border: 1px solid #ddd;
        border-radius: 5px;
        background-color: #fff;
        min-height: 250px;
        overflow-y: auto;
        font-size: 14px;
    }

    #analysis-panel-container {
        position: static;
        max-height: none;
    }

    #contract-text-display {
        min-height: 200px;
        padding: 8px;
        font-size: 13px;
        line-height: 1.4;
    }

    .contract-paragraph {
        padding: 3px 0;
        line-height: 1.4;
        margin: 0;
        font-size: 13px;
    }

    #analysis-results,
    .analysis-panel {
        min-height: 200px;
        padding: 10px;
        font-size: 13px;
    }

    #analysis-results h3,
    .analysis-panel h3 {
        margin-top: 0;
        margin-bottom: 8px;
        font-size: 16px;
    }

    #analysis-results p,
    .analysis-panel p {
        margin-bottom: 8px;
        font-size: 13px;
        line-height: 1.4;
    }

    section {
        margin-bottom: calc(var(--mobile-gutter) - 2px);
        padding-bottom: calc(var(--mobile-gutter) - 6px);
        padding: var(--mobile-card-padding);
    }

    .container {
        margin: calc(var(--mobile-gutter) - 2px) auto;
        padding: var(--mobile-card-padding);
    }

    .related-keywords-section {
        margin-bottom: 10px;
        padding: 10px;
    }

    .related-keywords-list {
        gap: 8px;
    }

    .related-keywords-list li {
        padding: 4px 8px;
        font-size: 12px;
    }

    .page-content {
        margin-bottom: 10px;
        padding: 10px;
        font-size: 14px;
    }

    /* Кнопки на мобиле */
    #analyze-button {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        margin-top: 10px;
    }

    #upload-section {
        margin-bottom: 15px;
    }

    #upload-section input[type="file"] {
        margin-right: 8px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 10px;
    }

    /* Прогресс-бар на мобиле */
    #progress-bar-container {
        margin-top: 10px;
    }

    #progress-bar {
        height: 20px;
        line-height: 20px;
        font-size: 12px;
    }

    #analysis-progress {
        margin-top: 8px;
        font-size: 13px;
    }

    footer {
        margin-top: 20px;
        font-size: 12px;
    }
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
    :root {
        --mobile-gutter: 12px;
        --mobile-card-padding: 16px;
    }

    body {
        padding: var(--mobile-gutter);
        font-size: 14px;
    }

    header {
        padding: 12px 0;
        margin-bottom: 12px;
    }

    .header-container {
        padding: 0 12px;
        gap: 10px;
        flex-direction: column;
    }

    .logo-text {
        font-size: 12px;
    }

    header h1 {
        font-size: 18px;
        line-height: 1.3;
    }

    main {
        padding: 0 var(--mobile-gutter) var(--mobile-gutter);
        border-radius: 10px;
    }

    body.product-default main {
        padding: 0;
    }

    /* Улучшаем читаемость текста */
    h1, h2, h3 {
        line-height: 1.3;
    }

    p {
        line-height: 1.4;
        font-size: 14px;
    }

    .two-column-layout {
        gap: 8px;
    }

    #contract-view-container, 
    .contract-form,
    #analysis-panel-container,
    .analysis-results {
        padding: 8px;
        font-size: 13px;
        min-height: 200px;
    }

    #contract-text-display {
        font-size: 12px;
        padding: 6px;
        line-height: 1.3;
    }

    .contract-paragraph {
        font-size: 12px;
        line-height: 1.3;
        padding: 2px 0;
    }

    #analysis-results,
    .analysis-panel {
        font-size: 12px;
        padding: 8px;
    }

    #analysis-results h3,
    .analysis-panel h3 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    #analysis-results p,
    .analysis-panel p {
        font-size: 12px;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    .container {
        padding: var(--mobile-card-padding);
    }

    .related-keywords-list li {
        padding: 3px 6px;
        font-size: 11px;
    }

    #analyze-button {
        padding: 10px 14px;
        font-size: 13px;
    }

    footer {
        font-size: 11px;
        margin-top: 15px;
        padding: 15px 8px;
    }

    /* Мобильные улучшения для форм и кнопок */
    input, textarea, select, button {
        font-size: 16px !important; /* Предотвращает зум на iOS */
        -webkit-appearance: none;
        border-radius: 8px;
    }

    button, .btn, input[type="submit"] {
        min-height: 44px; /* Минимальный размер для touch */
        padding: 12px 16px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Улучшаем отступы между интерактивными элементами */
    button + button, .btn + .btn {
        margin-top: 10px;
    }
}

/* Стили для админки - переопределяем базовые стили */
.admin-layout {
    background-color: #ecf0f1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.admin-layout main {
    background-color: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    max-width: none !important;
}

.admin-layout header {
    background: linear-gradient(135deg, #2c3e50, #3498db) !important;
    color: white !important;
    padding: 1.5rem 0 !important;
    margin-bottom: 0 !important;
    text-align: left !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
}

.admin-layout header h1,
.admin-layout header h2, 
.admin-layout header h3, 
.admin-layout header h4, 
.admin-layout header h5, 
.admin-layout header h6,
.admin-layout header p,
.admin-layout header a {
    color: white !important;
}

/* Фикс для products-grid на мобильных */
@media (max-width: 768px) {
    .products-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        margin-top: 15px !important;
    }
    
    .product-card {
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Фикс для продуктовых страниц - все grid layouts */
    .key-features div[style*="grid"],
    .key-benefits div[style*="grid"],
    .tech-specs div[style*="grid"],
    .use-cases div[style*="grid"],
    section div[style*="grid-template-columns"],
    div[style*="minmax("] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Фикс для форм заказа */
    .order-form-section,
    section[id*="order"],
    .form-container {
        max-width: 100% !important;
        padding: 15px 10px !important;
        margin: 10px 0 !important;
        box-sizing: border-box !important;
    }
}

/* Общие мобильные улучшения */
@media (max-width: 768px) {
    /* Отключаем горизонтальную прокрутку */
    html, body {
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
    }

    * {
        max-width: 100%;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Специальные исправления для продуктовых страниц */
    .product-default main {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .product-default section {
        max-width: 100% !important;
        overflow-x: hidden !important;
        padding: 15px 10px !important;
    }

    .product-default div[style*="max-width: 1200px"] {
        max-width: 100% !important;
        padding: 0 !important;
    }

    /* Исправление для inline стилей с фиксированными размерами */
    .product-default div[style*="minmax(300px"],
    .product-default div[style*="minmax(350px"],
    .product-default div[style*="minmax(250px"] {
        grid-template-columns: 1fr !important;
    }

    /* КРИТИЧНО: Адаптив формы заказа */
    .order-form-section {
        padding: 15px 10px !important;
        margin: 15px 0 !important;
    }

    .order-form-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .order-form-input,
    .order-form-benefits {
        padding: 15px !important;
        margin: 0 !important;
    }

    .order-form-section h2 {
        font-size: 1.4em !important;
        margin-bottom: 15px !important;
    }

    .order-form-section h3 {
        font-size: 1.1em !important;
        margin-bottom: 12px !important;
    }
}

/* Основные стили для админки */
.contract-analysis-pre-main {
    width: 100%;
}

.contract-analysis-pre-main {
    background: #f8fafc;
    margin-bottom: 40px;
}

.contract-analysis-pre-main section {
    width: 100%;
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.contract-analysis-wide {
    width: min(1600px, 94vw);
    margin: 0 auto;
}

.contract-analysis-upload {
    background: #f2f7fb;
    padding: 30px 0;
}

.contract-analysis-main {
    padding: 10px 0 60px;
    background: #f8fafc;
}

.contract-analysis-order {
    padding: 50px 0 70px !important;
}

.contract-hero {
    padding: 30px 0;
}

#upload-section input[type="file"] {
