:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #20242a;
    --border: #d9dde3;
    --warning: #fff0b3;
    --warning-border: #d79b00;
    --accent: #2481cc;
}

* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.app {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 12px;
}

.header h1 {
    margin: 0;
    font-size: 24px;
}

.header p {
    margin: 6px 0 20px;
    color: #667085;
}

.summary, .review {
    width: 100%;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

h2 {
    font-size: 16px;
    margin: 0 0 12px;
}

.table-container {
    width: 100%;
    overflow-x: hidden;
}

table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
}

th, td {
    border: 1px solid var(--border);
    padding: 6px;
    text-align: left;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

th {
    background: #edf0f4;
    font-weight: 600;
}

th:nth-child(1) { width: 6%; }
th:nth-child(2) { width: 16%; }
th:nth-child(3) { width: 49%; }
th:nth-child(4) { width: 6%; }
th:nth-child(5) { width: 6%; }
th:nth-child(6) { width: 6%; }
th:nth-child(7) { width: 11%; }

tr.section-row td {
    background: #e9edf2;
    font-weight: bold;
}

td.problem-cell {
    background: var(--warning);
    box-shadow: inset 0 0 0 1px var(--warning-border);
}

td textarea {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 28px;
    padding: 4px;
    margin: 0;
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

td textarea:focus {
    outline: 2px solid var(--accent);
    background: white;
}

.footer {
    position: sticky;
    bottom: 0;
    padding: 10px 0;
    background: var(--bg);
}

#confirmButton {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-weight: bold;
    cursor: pointer;
}

#confirmButton:disabled {
    background: #aab2bd;
    cursor: not-allowed;
}

/* Automatic Russian word hyphenation */

table {
    hyphens: auto;
    -webkit-hyphens: auto;
}

th, td {
    overflow-wrap: normal;
    word-break: normal;
    hyphens: auto;
    -webkit-hyphens: auto;
}

td textarea {
    overflow-wrap: normal;
    word-break: normal;
    hyphens: auto;
    -webkit-hyphens: auto;
}
td select {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 4px 1px;
    border: 1px solid #d79b00;
    border-radius: 4px;
    background: #fff8dc;
    color: #20242a;
    font: inherit;
}
/* SmetaAI: adaptive specification table */

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.table-container table {
    width: 100%;
    min-width: 900px;
    table-layout: fixed;
}

/* Column widths */

.table-container th:nth-child(1) { width: 7%; }
.table-container th:nth-child(2) { width: 18%; }
.table-container th:nth-child(3) { width: 43%; }
.table-container th:nth-child(4) { width: 7%; }
.table-container th:nth-child(5) { width: 7%; }
.table-container th:nth-child(6) { width: 7%; }
.table-container th:nth-child(7) { width: 11%; }

/* Readable text */

.table-container th,
.table-container td {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
    -webkit-hyphens: none;
}

.table-container td textarea {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
    -webkit-hyphens: none;
}

/* Mobile screens */

@media (max-width: 768px) {
    .app {
        padding: 10px;
    }

    .summary,
    .review {
        padding: 10px;
    }

    .table-container table {
        min-width: 900px;
    }
}
/* SmetaAI — mobile specification cards */

@media (max-width: 767px) {

    .table-container {
        overflow-x: visible;
        overflow-y: visible;
    }

    .table-container table {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .table-container thead {
        display: none;
    }

    .table-container tbody {
        display: block;
        width: 100%;
    }

    .table-container tr {
        display: block;
        width: 100%;
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid #d9dde3;
        border-radius: 8px;
        background: #fff;
    }

    .table-container td {
        display: block;
        width: 100%;
        padding: 6px 0;
        border: none;
    }

    .table-container tr:not(.section-row) td::before {
        display: block;
        margin-bottom: 4px;
        color: #667085;
        font-size: 12px;
        font-weight: 600;
    }

    .table-container td:nth-child(1)::before {
        content: "Позиция / Марка";
    }

    .table-container td:nth-child(2)::before {
        content: "Обозначение";
    }

    .table-container td:nth-child(3)::before {
        content: "Наименование";
    }

    .table-container td:nth-child(4)::before {
        content: "Ед. изм.";
    }

    .table-container td:nth-child(5)::before {
        content: "Количество";
    }

    .table-container td:nth-child(6)::before {
        content: "Масса";
    }

    .table-container td:nth-child(7)::before {
        content: "Примечание";
    }

    .table-container td textarea,
    .table-container td select {
        width: 100%;
        min-width: 0;
        padding: 8px;
        border: 1px solid #d9dde3;
        border-radius: 5px;
        font-size: 14px;
        background: #fff;
    }

    .table-container td.problem-cell {
        padding: 6px;
        border-radius: 5px;
    }

    .table-container tr.section-row {
        background: #e9edf2;
        font-weight: bold;
    }

    .table-container tr.section-row td {
        display: block;
        width: 100%;
        background: transparent;
    }
}
/* Убираем подпись поля у заголовков разделов */
@media (max-width: 767px) {
    .table-container tr.section-row td::before {
        content: none !important;
        display: none !important;
    }
}
/* SmetaAI — перенос слов в заголовках таблицы */

@media (min-width: 768px) {

    .table-container th {
        overflow-wrap: normal;
        word-break: normal;

        hyphens: auto;
        -webkit-hyphens: auto;

        white-space: normal;
        line-height: 1.4;
        vertical-align: middle;
    }

    .table-container th:nth-child(1) {
        width: 12%;
    }

    .table-container th:nth-child(2) {
        width: 17%;
    }

    .table-container th:nth-child(3) {
        width: 35%;
    }

    .table-container th:nth-child(4) {
        width: 9%;
    }

    .table-container th:nth-child(5) {
        width: 10%;
    }

    .table-container th:nth-child(6) {
        width: 7%;
    }

    .table-container th:nth-child(7) {
        width: 10%;
    }
}