/* =========================================
   1. СЕТКА И БАЗОВЫЙ ЛЕЙАУТ (WEB APP)
   ========================================= */
.tools-main-wrapper { 
    padding: 30px 20px; 
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.tool-container-centered {
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.tool-app-container {
    background: var(--white);
    padding: 30px 35px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

.tool-section {
    margin-bottom: 25px;
}

.tool-section:not(:last-child) {
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 20px;
}

/* =========================================
   2. ТИПОГРАФИКА И УТИЛИТЫ
   ========================================= */
.tool-title { 
    font-size: 1.4rem; 
    font-weight: 800; 
    color: var(--brand-dark); 
    margin: 0 0 20px 0; 
}

.tool-desc, p {
    line-height: 1.6;
    margin-top: 0;
    margin-bottom: 20px;
    color: #475569;
}

.font-mono { 
    font-family: var(--font-main), sans-serif; 
    font-variant-numeric: tabular-nums; /* Ровные цифры в таблицах */
}

.fw-700 { font-weight: 700; }
.color-brand { color: var(--brand-dark); }
.color-slate { color: #64748b; }
.bg-disabled { background: #f1f5f9; color: #64748b; pointer-events: none; }
.text-center { text-align: center; }
.w-100 { width: 100%; }

.mt-0 { margin-top: 0; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-25 { margin-bottom: 25px; }

/* =========================================
   3. ФОРМЫ (ИНПУТЫ, СЕЛЕКТЫ, ЛЕЙБЛЫ)
   ========================================= */
.tool-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.tool-form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 140px;
}

.tool-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
    display: block;
}

/* Единый стиль полей с защитой от обрезания текста */
.tool-input, .tool-select, .mm-input {
    height: 40px;
    line-height: 38px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: var(--font-main), sans-serif;
    font-weight: 500;
    background: var(--white);
    color: var(--brand-dark);
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.mm-input {
    font-weight: 700;
}

.tool-input:focus, .tool-select:focus, .mm-input:focus {
    outline: none;
    border-color: var(--magenta);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--magenta) transparent 90%);
}

.tool-input.is-invalid { 
    border-color: var(--color-error); 
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.1); 
}

textarea.tool-input { 
    height: auto; 
    min-height: 100px; 
    line-height: 1.5; 
    padding: 12px;
}

/* Сдвоенные поля (инпут + селект) */
.input-group { display: flex; width: 100%; }
.input-group-main { flex: 1; border-radius: 6px 0 0 6px; }
.input-group-select { border-radius: 0 6px 6px 0; border-left: none; background: #f8fafc; width: auto; min-width: 100px; flex-shrink: 0; }
.input-group-addon { padding: 0 12px; height: 40px; line-height: 38px; border: 1px solid #cbd5e1; border-left: none; border-radius: 0 6px 6px 0; background: #f1f5f9; color: #64748b; display: flex; align-items: center; font-size: 0.95rem; }

/* =========================================
   4. КНОПКИ
   ========================================= */
.tool-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 40px;
    background: var(--brand-dark);
    color: var(--white);
    border: none;
    padding: 0 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.tool-btn-primary:hover {
    background: var(--magenta);
    transform: translateY(-1px);
    box-shadow: var(--shadow-magenta-glow);
    color: var(--white);
}

.add-insert-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 40px;
    background: transparent;
    color: var(--brand-dark);
    border: 1px solid #cbd5e1;
    width: 100%;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    margin-top: 8px;
    margin-bottom: 15px;
}

.add-insert-btn:hover {
    background: #f8fafc;
    border-color: var(--brand-dark);
}

.back-link-wrapper { margin-bottom: 15px; }
.back-link { display: inline-flex; align-items: center; color: var(--magenta); font-weight: 800; font-size: 0.85rem; text-decoration: none; text-transform: uppercase; transition: 0.2s; }
.back-link:hover { opacity: 0.7; }

/* =========================================
   5. ТАБЛИЦЫ
   ========================================= */
.mm-table, .results-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
    font-size: 0.9rem; 
}

.mm-table th, .results-table th { 
    color: #64748b; 
    font-weight: 700; 
    background: #f8fafc; 
    text-transform: uppercase; 
    font-size: 0.8rem;
    padding: 8px 12px; 
    border-bottom: 1px solid #e2e8f0; 
    text-align: left;
}

.mm-table td, .results-table td { 
    padding: 6px 12px; 
    height: 45px;
    border-bottom: 1px solid #e2e8f0; 
    vertical-align: middle;
}

.mm-total-row { 
    font-weight: 800; 
    background: #f8fafc; 
    color: var(--brand-dark); 
}

/* Компактные инпуты внутри таблиц */
.results-table input.mm-input,
.results-table select.tool-select {
    height: 34px;
    line-height: 32px;
    padding: 0 8px;
    font-size: 0.85rem;
    border-radius: 4px;
}

/* =========================================
   6. ВКЛАДКИ (TABS)
   ========================================= */
.tool-tabs {
    display: flex;
    gap: 20px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tool-tabs::-webkit-scrollbar { display: none; }

.tool-tab-btn {
    background: none;
    border: none;
    padding: 10px 5px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; 
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tool-tab-btn:hover { color: var(--brand-dark); }
.tool-tab-btn.active { color: var(--magenta); border-bottom-color: var(--magenta); }

.tool-tab-pane { display: none; animation: fadeIn 0.3s ease; }
.tool-tab-pane.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   7. УВЕДОМЛЕНИЯ И БАННЕРЫ
   ========================================= */
.validation-warning {
    display: none; 
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: #fef2f2;
    border-left: 4px solid var(--color-error);
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #991b1b;
}

.validation-warning.info-mode {
    background: #f0fdfa;
    border-color: #3b82f6;
    color: #1e40af;
}

.integrated-promo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: linear-gradient(135deg, #fef5ff 0%, #ffffff 100%);
    border: 1px solid rgba(236, 0, 140, 0.15);
    border-left: 4px solid var(--magenta);
    padding: 20px 25px;
    border-radius: 8px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.integrated-promo-content h4 {
    margin: 0 0 5px 0;
    color: var(--brand-dark);
    font-size: 1.05rem;
    font-weight: 800;
}

.integrated-promo-content p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-main);
}

.integrated-promo .tool-btn-primary { margin: 0; }

/* =========================================
   8. СПЕЦИФИЧНЫЕ МОДУЛИ
   ========================================= */

/* Панель экспорта */
.export-bar {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px dashed #e2e8f0;
    justify-content: flex-end;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 40px;
    background: #f8fafc;
    color: var(--brand-dark);
    border: 1px solid #cbd5e1;
    padding: 0 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-export:hover {
    background: #e2e8f0;
    border-color: var(--brand-dark);
}

/* Лигирование */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: end;
}

.optional-badge {
    background: #e2e8f0;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 5px;
    vertical-align: middle;
    text-transform: uppercase;
    font-weight: 800;
}

.insert-row-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    transition: border-color 0.2s ease;
}

.insert-row-card:hover { border-color: var(--brand-dark); }

.insert-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 10px;
}

.insert-row-card .remove-insert-btn {
    position: static;
    background: #fef2f2;
    color: #ef4444;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.insert-row-card .remove-insert-btn:hover {
    background: #ef4444;
    color: #fff;
}

/* Анализатор белков */
.aa-acidic { color: #ef4444; font-weight: 700; }
.aa-basic { color: #3b82f6; font-weight: 700; }
.aa-polar { color: #10b981; font-weight: 700; }
.aa-nonpolar { color: #64748b; font-weight: 700; }

.aa-comp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.aa-comp-item {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.aa-comp-item span:last-child { color: var(--brand-dark); }

/* Хаб инструментов (Главная) */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.tool-card {
    background: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 25px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.06);
    border-color: var(--magenta);
}

.tool-icon {
    width: 6rem;         /* Фиксируем аккуратный размер */
    height: 6rem;
    margin-bottom: 20px; /* Отступ до заголовка */
    align-self: center;  /* Выравнивает только иконку по центру карточки */
    display: block;      /* На всякий случай, если flex отключится */
}
.tool-card .tool-title { font-size: 1.25rem; margin-bottom: 10px; }
.tool-card .tool-desc { font-size: 0.95rem; color: #64748b; margin: 0; }

/* =========================================
   9. АДАПТИВ (MEDIA QUERIES)
   ========================================= */
@media (max-width: 768px) {
    .mw-purity-row, .form-grid-3 { grid-template-columns: 1fr; gap: 15px; }
    .integrated-promo { flex-direction: column; align-items: stretch; text-align: center; }
}

@media print {
    body { background: var(--white); }
    #header-placeholder, #footer-placeholder, .site-header, .site-footer, aside, 
    .tool-breadcrumbs, .back-link-wrapper, button, .integrated-promo, .export-bar { 
        display: none !important; 
    }
    .tool-app-container { box-shadow: none; border: none; padding: 0; }
}