:root {
    --primary: #0f766e;
    --primary-hover: #0d9488;
    --primary-light: #f0fdfa;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --danger: #ef4444;
    --success: #059669;

    --state-green: #059669;
    --state-green-bg: #ecfdf5;
    --state-yellow: #d97706;
    --state-yellow-bg: #fffbeb;
    --state-orange: #ea580c;
    --state-orange-bg: #fff7ed;
    --state-red: #dc2626;
    --state-red-bg: #fef2f2;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
}

body { 
    background-color: var(--bg); 
    color: var(--text-main); 
    padding: 1.25rem; 
    line-height: 1.5; 
    font-size: 14px;
}

.container { 
    max-width: 1440px; 
    margin: 0 auto; 
}

/* Компактная шапка приложения */
/* Верхняя строгая строка-шапка */
.app-top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.header-left-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.header-icon {
    font-size: 1.4rem;
}

.app-top-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.autosave-badge {
    font-size: 0.75rem;
    color: #0f766e;
    font-weight: 600;
    background: #ccfbf1;
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    border: 1px solid #99f6e4;
}

.header-status-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-online-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
}

.status-dot {
    color: #10b981;
    font-size: 0.65rem;
}

.btn-text-danger {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    transition: opacity 0.15s;
}

.btn-text-danger:hover {
    opacity: 0.8;
}

/* Вкладки в виде кнопок-чипов как на образце */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    background: #e2e8f0;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    transition: all 0.15s ease-in-out;
}

.tab-btn:hover {
    background: #cbd5e1;
    border-color: #94a3b8;
}

.tab-btn.active {
    background: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
    box-shadow: 0 1px 3px rgba(15, 118, 110, 0.25);
}

.tab-icon {
    font-size: 0.9rem;
}

.tab-btn:hover {
    background: #cbd5e1;
}

.tab-btn.active { 
    background: var(--primary); 
    color: #ffffff; 
}

.tab-content { 
    display: none; 
}

.tab-content.active { 
    display: block; 
}

/* Двухколоночный макет */
.layout { 
    display: flex; 
    gap: 1.5rem; 
    align-items: flex-start; 
}

.left-panel { 
    flex: 3; 
    display: flex; 
    flex-direction: column; 
    gap: 0.85rem; 
    min-width: 0; 
}

.right-panel { 
    flex: 1.5; 
    position: sticky; 
    top: 1rem; 
    display: flex; 
    flex-direction: column; 
    gap: 1rem; 
    min-width: 330px; 
    max-height: calc(100vh - 2rem); 
    overflow-y: auto; 
    padding-right: 2px; 
}

/* Панель «Отображение и точность» над списком */
.workspace-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.toolbar-group { 
    display: flex; 
    align-items: center; 
    gap: 0.4rem; 
}

.toolbar-label { 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--text-muted); 
}

.toolbar-select { 
    padding: 0.35rem 0.55rem; 
    font-size: 0.82rem; 
    border: 1px solid var(--border); 
    border-radius: 4px; 
    background: #ffffff; 
    cursor: pointer; 
    color: var(--text-main);
    outline: none;
    transition: border-color 0.15s;
}

.toolbar-select:focus {
    border-color: var(--primary);
}

.toolbar-divider { 
    width: 1px; 
    height: 22px; 
    background: #e2e8f0; 
}

.toolbar-action { 
    margin-left: auto; 
}

.btn-chip { 
    background: #f8fafc; 
    border: 1px solid var(--border); 
    color: var(--text-main); 
    padding: 0.35rem 0.65rem; 
    border-radius: 5px; 
    font-size: 0.78rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.15s; 
}

.btn-chip:hover { 
    border-color: var(--primary); 
    color: var(--primary); 
    background: var(--primary-light); 
}

/* Карточки */
.card { 
    background-color: var(--card-bg); 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    padding: 1.1rem; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.04); 
}

.card-section-title { 
    font-size: 0.85rem; 
    font-weight: 700; 
    color: var(--text-main); 
}

/* Правая панель: блок результата */
.summary-box { 
    background: #ecfdf5; 
    border: 1px solid #a7f3d0; 
    border-radius: 8px;
    padding: 1.25rem; 
}

.summary-caption { 
    text-align: center; 
    font-size: 0.95rem; 
    font-weight: 600; 
    color: #065f46; 
}

.summary-result { 
    font-size: 3.2rem; 
    font-weight: 800; 
    color: var(--success); 
    text-align: center; 
    line-height: 1; 
    margin: 0.4rem 0; 
}

.summary-subtext { 
    text-align: center; 
    font-size: 0.82rem; 
    color: #047857; 
    margin-bottom: 0.75rem; 
    line-height: 1.45;
}

/* Сетка кнопок экспорта */
.export-actions-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 0.5rem; 
    margin-top: 0.5rem; 
}

.btn-export-pdf { 
    background: #1e293b; 
    color: #ffffff; 
    font-weight: 600; 
    font-size: 0.8rem; 
    padding: 0.55rem 0.5rem; 
    border-radius: 6px; 
    border: none; 
    cursor: pointer; 
    text-align: center; 
    transition: background 0.15s;
}

.btn-export-pdf:hover { 
    background: #0f172a; 
}

.btn-export-excel { 
    background: #065f46; 
    color: #ffffff; 
    font-weight: 600; 
    font-size: 0.8rem; 
    padding: 0.55rem 0.5rem; 
    border-radius: 6px; 
    border: none; 
    cursor: pointer; 
    text-align: center; 
    transition: background 0.15s;
}

.btn-export-excel:hover { 
    background: #047857; 
}

/* Блок математического обоснования */
.math-details { 
    margin-top: 0.75rem; 
}

.math-details summary { 
    cursor: pointer; 
    color: var(--primary); 
    font-size: 0.8rem; 
    font-weight: 700; 
    user-select: none; 
}

.math-box { 
    background: #1e293b; 
    color: #cbd5e1; 
    padding: 0.75rem; 
    border-radius: 4px; 
    margin-top: 0.4rem; 
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; 
    font-size: 0.75rem; 
    white-space: pre-wrap; 
    overflow-x: auto; 
    line-height: 1.45;
}

/* Правая панель: шаблоны */
.control-card { 
    display: flex; 
    flex-direction: column; 
    gap: 0.65rem; 
}

.preset-items-stack { 
    display: flex; 
    flex-direction: column; 
    gap: 0.4rem; 
}

.preset-item-card { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #ffffff; 
    border: 1px solid var(--border); 
    border-radius: 6px; 
    padding: 0.5rem 0.65rem; 
    cursor: pointer; 
    text-align: left; 
    transition: all 0.15s ease-in-out; 
}

.preset-item-card:hover { 
    border-color: var(--primary); 
    background: var(--primary-light); 
    transform: translateY(-1px); 
}

.preset-item-card.is-active { 
    border-color: var(--primary); 
    background: var(--primary-light); 
    border-left: 4px solid var(--primary); 
}

.preset-item-content { 
    display: flex; 
    flex-direction: column; 
    gap: 0.1rem; 
    min-width: 0; 
}

.preset-item-code { 
    font-size: 0.68rem; 
    font-weight: 700; 
    color: var(--primary); 
    text-transform: uppercase; 
    letter-spacing: 0.3px;
}

.preset-item-title { 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--text-main); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.preset-check-icon { 
    color: var(--primary); 
    font-weight: 800; 
    font-size: 0.95rem; 
    margin-left: 0.5rem; 
}

/* Сводка и список потребителей */
.summary-list-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 0.5rem; 
    margin-bottom: 0.75rem; 
}

.summary-list-header h3 { 
    font-size: 0.95rem; 
    font-weight: 700;
}

.elements-stack { 
    display: flex; 
    flex-direction: column; 
    gap: 0.65rem; 
}

.accordion-card { 
    border: 1px solid var(--border); 
    border-radius: 6px; 
    overflow: hidden; 
    transition: all 0.15s ease-in-out; 
    border-left: 5px solid var(--border); 
}

.accordion-card.state-green { 
    border-left-color: var(--state-green) !important; 
}

/* Формы */
.form-row { 
    display: flex; 
    gap: 0.75rem; 
    margin-bottom: 0.65rem; 
    flex-wrap: wrap;
}

.form-group { 
    flex: 1; 
    min-width: 140px; 
}

.form-group label { 
    display: block; 
    margin-bottom: 0.25rem; 
    font-weight: 600; 
    font-size: 0.8rem; 
    color: var(--text-muted); 
}

select, input[type="number"], input[type="text"] { 
    width: 100%; 
    padding: 0.45rem 0.65rem; 
    border: 1px solid var(--border); 
    border-radius: 4px; 
    font-size: 0.85rem; 
    color: var(--text-main);
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s;
}

select:focus, input:focus { 
    border-color: var(--primary); 
}

.normative-hint { 
    font-size: 0.78rem; 
    color: var(--text-muted); 
    margin-top: 0.5rem; 
    font-style: italic; 
    line-height: 1.4;
    background: var(--bg);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border-left: 3px solid var(--primary);
}

/* Кнопки */
.btn { 
    background-color: var(--primary); 
    color: #ffffff; 
    border: none; 
    padding: 0.45rem 0.85rem; 
    border-radius: 4px; 
    cursor: pointer; 
    font-weight: 600; 
    font-size: 0.8rem; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}

.btn:hover { 
    background-color: var(--primary-hover); 
}

.btn-primary { 
    background-color: var(--primary); 
    color: #ffffff; 
}

.btn-outline { 
    background: transparent; 
    border: 1px dashed var(--primary); 
    color: var(--primary); 
}

.btn-outline:hover {
    background: var(--primary-light);
}

.btn-sm { 
    padding: 0.3rem 0.6rem; 
    font-size: 0.75rem; 
}

.btn-add-main { 
    width: 100%; 
    padding: 0.65rem; 
    border: 2px dashed var(--border); 
    background: transparent; 
    color: var(--text-muted); 
    cursor: pointer; 
    border-radius: 8px; 
    font-size: 0.85rem; 
    font-weight: 600;
    transition: all 0.15s;
}

.btn-add-main:hover { 
    border-color: var(--primary); 
    color: var(--primary); 
    background: var(--primary-light); 
}

/* Бейджи */
.badge { 
    display: inline-block;
    padding: 0.2rem 0.5rem; 
    border-radius: 4px; 
    font-size: 0.75rem; 
    font-weight: 700; 
    border: 1px solid transparent; 
}

.badge-green { 
    background: var(--state-green-bg); 
    color: var(--state-green); 
    border-color: #a7f3d0; 
}

.badge-yellow { 
    background: var(--state-yellow-bg); 
    color: var(--state-yellow); 
    border-color: #fde68a; 
}

.badge-orange { 
    background: var(--state-orange-bg); 
    color: var(--state-orange); 
    border-color: #fed7aa; 
}

.badge-red { 
    background: var(--state-red-bg); 
    color: var(--state-red); 
    border-color: #fecaca; 
}

.badge-subtle { 
    background: #f1f5f9; 
    color: #64748b; 
    font-weight: 600; 
    border-color: #e2e8f0; 
}

/* Карточка СП 484 / ГОСТ */
.gost-card { 
    background: #ffffff; 
    border-left: 4px solid var(--primary); 
}

.gost-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.gost-text-block { 
    font-size: 0.82rem; 
    color: #334155; 
    line-height: 1.45; 
    background: #f8fafc; 
    border: 1px solid #e2e8f0; 
    border-radius: 6px; 
    padding: 0.65rem; 
    margin-top: 0.4rem; 
}

/* Проверка ЗУ РИП (Блоки интерполяции / верификации) */
.auto-interp-card { 
    background: #f0fdfa; 
    border: 1px solid #99f6e4; 
    border-radius: 6px; 
    padding: 0.75rem 0.95rem; 
    margin-top: 0.5rem; 
}

.interp-disabled-card { 
    background: #fffbeb; 
    border: 1px solid #fde68a; 
    border-radius: 6px; 
    padding: 0.75rem 0.95rem; 
    color: #92400e; 
    font-size: 0.82rem; 
    line-height: 1.4; 
    margin-top: 0.5rem; 
}

.interp-input-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 1rem; 
}

.unit-badge { 
    background: #ccfbf1; 
    color: #0f766e; 
    font-size: 0.78rem; 
    font-weight: 700; 
    padding: 0.3rem 0.55rem; 
    border-radius: 4px; 
    border: 1px solid #99f6e4; 
    white-space: nowrap; 
}

.interp-calc-proof { 
    margin-top: 0.45rem; 
    padding-top: 0.45rem; 
    border-top: 1px dashed #99f6e4; 
    font-size: 0.78rem; 
    color: #0f172a; 
    line-height: 1.4; 
}

/* Каталог и таблицы */
.statement-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-wrap: wrap; 
    gap: 1rem; 
    margin-bottom: 1rem; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 0.75rem; 
}

.statement-table-box { 
    overflow-x: auto; 
    border: 1px solid var(--border);
    border-radius: 6px;
}

.statement-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 0.85rem; 
}

.statement-table th, .statement-table td { 
    border-bottom: 1px solid var(--border); 
    padding: 0.6rem 0.75rem; 
    vertical-align: middle; 
}

.statement-table th { 
    background: #f1f5f9; 
    font-weight: 700; 
    color: var(--text-main); 
    text-align: left; 
}

.statement-table tr:hover { 
    background: #f8fafc; 
}

/* Фильтры каталога (Таблетки) */
.mode-pills-row { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 0.35rem; 
    margin-bottom: 0.75rem; 
}

.mode-pill-label { 
    display: inline-flex; 
    align-items: center; 
    background: #ffffff; 
    border: 1px solid #cbd5e1; 
    padding: 0.3rem 0.65rem; 
    border-radius: 4px; 
    font-size: 0.76rem; 
    font-weight: 600; 
    color: #475569; 
    cursor: pointer; 
    transition: all 0.15s; 
}

.mode-pill-label:hover { 
    border-color: var(--primary); 
    color: var(--primary); 
}

.mode-pill-label.active { 
    background: var(--primary); 
    border-color: var(--primary); 
    color: #ffffff; 
}

.mode-pill-label input[type="radio"] { 
    display: none; 
}

/* Поиск */
.search-filter-box input { 
    background: #ffffff; 
    border: 1px solid #cbd5e1; 
    border-radius: 4px; 
    padding: 0.4rem 0.65rem; 
    font-size: 0.82rem; 
}

/* Модальные окна */
.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    background: rgba(15, 23, 42, 0.6); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 9999; 
    padding: 1rem; 
}

.modal-container { 
    background: #ffffff; 
    width: 100%; 
    max-width: 950px; 
    max-height: 90vh; 
    border-radius: 8px; 
    display: flex; 
    flex-direction: column; 
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); 
    overflow: hidden; 
}

.modal-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0.85rem 1.25rem; 
    border-bottom: 1px solid var(--border); 
    background: #f8fafc; 
}

.print-document-body { 
    background: #ffffff; 
    color: #000000; 
    padding: 2rem; 
    font-family: 'Times New Roman', Times, serif; 
    line-height: 1.35; 
    overflow-y: auto; 
}

.act-header-normative { 
    text-align: right; 
    font-size: 0.85rem; 
    margin-bottom: 1rem; 
}

.act-title-main { 
    text-align: center; 
    font-size: 1.25rem; 
    font-weight: bold; 
    margin-bottom: 1.25rem; 
}

.act-object-props { 
    display: flex; 
    flex-direction: column; 
    gap: 0.4rem; 
    margin-bottom: 1rem; 
    font-size: 0.9rem; 
}

.props-row { 
    display: flex; 
    align-items: center; 
}

.props-label { 
    font-weight: bold; 
    margin-right: 0.5rem; 
    min-width: 140px; 
}

.props-input { 
    border: none; 
    border-bottom: 1px solid #000000; 
    font-family: inherit; 
    font-size: inherit; 
    padding: 0.1rem 0.25rem; 
    flex: 1; 
    background: transparent; 
}

.props-input:focus { 
    outline: none; 
    border-bottom: 2px solid var(--primary); 
}

.act-vsn-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 0.5rem; 
    margin-bottom: 1rem; 
    font-size: 0.85rem; 
}

.act-vsn-table th, .act-vsn-table td { 
    border: 1px solid #000000; 
    padding: 0.4rem 0.5rem; 
}

.act-vsn-table th { 
    background: #f8fafc; 
    font-weight: bold; 
    text-align: center; 
}

.tr-total { 
    background: #f1f5f9; 
}

.act-verdict-box { 
    margin-top: 0.75rem; 
    font-size: 0.95rem; 
    padding: 0.6rem; 
    border: 1px solid #000000; 
    background: #fafafa; 
}

.act-signatures-block { 
    margin-top: 1.5rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.75rem; 
}

.signature-line-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 1rem; 
}

.sig-role { 
    border: none; 
    border-bottom: 1px solid #000000; 
    flex: 1; 
    font-family: inherit; 
    font-size: inherit; 
    padding: 0.1rem; 
}

.sig-space { 
    font-family: inherit; 
    font-size: 0.9rem; 
    white-space: nowrap; 
}

/* Правила печати */
/* Правила печати и сохранения в PDF */
@media print {
    body { 
        background: #ffffff !important; 
        padding: 0 !important; 
        margin: 0 !important; 
    }
    /* Скрываем интерфейс калькулятора, оставляя контейнер */
    .no-print, .tabs, .app-top-header, .layout, #modalCatalogQuickAdd { 
        display: none !important; 
    }
    .container { 
        max-width: 100% !important; 
        padding: 0 !important; 
        margin: 0 !important; 
    }
    #modalPrintReport { 
        position: static !important; 
        background: none !important; 
        padding: 0 !important; 
        display: block !important; 
    }
    #modalPrintReport .modal-container { 
        box-shadow: none !important; 
        max-width: 100% !important; 
        max-height: none !important; 
        border: none !important; 
        overflow: visible !important; 
    }
    .print-document-body { 
        padding: 0 !important; 
        font-size: 11pt !important; 
        overflow: visible !important; 
    }
    .act-vsn-table th { 
        background: #e5e5e5 !important; 
        -webkit-print-color-adjust: exact; 
        print-color-adjust: exact; 
    }
    .props-input, .sig-role { 
        border-bottom: 1px solid #000 !important; 
    }
}

/* Адаптивность для мобильных и планшетов */
@media (max-width: 1024px) {
    .layout { 
        flex-direction: column; 
    }
    .right-panel { 
        position: static; 
        width: 100%; 
        max-height: none; 
    }
}