/* =====================================================================
   CARBONEXT LAB — журнал экстракции
   Фирменный стиль КарбонЭКСТ (carbon-ext.ru): графит, бирюза, светлый
   фон, Nunito Sans, прямые углы. Шрифт лежит локально в static/fonts.
   ===================================================================== */

@font-face {
    font-family: "Nunito Sans";
    src: url("fonts/nunito-sans-cyrillic-full-normal.woff2") format("woff2");
    font-weight: 200 1000;
    font-stretch: 75% 125%;
    font-display: swap;
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "Nunito Sans";
    src: url("fonts/nunito-sans-latin-full-normal.woff2") format("woff2");
    font-weight: 200 1000;
    font-stretch: 75% 125%;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
        U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
        U+FEFF, U+FFFD;
}

:root {
    /* фирменные */
    --graphite: #323e48;
    --graphite-deep: #252e36;
    --cyan: #00c1d5;
    --cyan-ink: #00808e;      /* бирюза для текста на белом (контраст 4.6:1) */
    --cyan-wash: #e3f8fa;
    --magenta: #cc3366;       /* ошибки и удаление */
    --magenta-wash: #fbe9ef;

    /* нейтральные */
    --paper: #f7f7f7;
    --white: #ffffff;
    --ink: #2f3a43;
    --muted: #69727d;
    --line: #dfdfdf;
    --line-strong: #c9ced3;

    --font: "Nunito Sans", "Segoe UI", Roboto, Arial, sans-serif;
    --step--1: 0.8125rem;   /* 13 */
    --step-0: 1rem;         /* 16 */
    --step-1: 1.25rem;      /* 20 */
    --step-2: 1.625rem;     /* 26 */
    --step-3: 2.125rem;     /* 34 */
    --gutter: clamp(16px, 3vw, 32px);
    --focus: 0 0 0 3px rgba(0, 193, 213, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--step-0);
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

a {
    color: var(--cyan-ink);
}

h1,
h2,
h3,
h4 {
    margin: 0;
    color: var(--graphite);
    line-height: 1.2;
}

/* Заголовки страниц — прописными, как на сайте компании */
.page-title {
    font-size: var(--step-2);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.01em;
}

h2 {
    font-size: var(--step-1);
    font-weight: 800;
}

h3 {
    font-size: 1.0625rem;
    font-weight: 800;
}

code,
.code-block {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.875em;
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 0.05em 0.35em;
}

.code-block {
    display: block;
    padding: 0.6rem 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Шапка
   --------------------------------------------------------------------- */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--gutter);
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 40px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--graphite);
    flex-shrink: 0;
}

.brand img {
    height: 22px;
    width: auto;
    display: block;
}

.wordmark {
    font-weight: 800;
    font-size: 1.375rem;
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--graphite);
}

.wordmark-tag {
    font-size: var(--step--1);
    font-weight: 700;
    color: var(--muted);
    padding-left: 12px;
    border-left: 1px solid var(--line);
    line-height: 1.2;
}

.mainnav {
    display: flex;
    align-items: stretch;
    align-self: stretch;
    gap: 4px;
}

.mainnav a {
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: var(--graphite);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9375rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.mainnav a:hover {
    color: var(--cyan-ink);
}

.mainnav a[aria-current="page"] {
    border-bottom-color: var(--cyan);
}

.userbox {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.875rem;
    color: var(--muted);
}

.userbox strong {
    color: var(--graphite);
}

@media (max-width: 760px) {
    .topbar-inner {
        flex-wrap: wrap;
        gap: 0 16px;
        padding-top: 12px;
    }

    .wordmark-tag {
        display: none;
    }

    .mainnav {
        order: 3;
        width: calc(100% + 2 * var(--gutter));
        margin: 8px calc(-1 * var(--gutter)) 0;
        padding: 0 calc(var(--gutter) - 14px);
        border-top: 1px solid var(--line);
        overflow-x: auto;
        min-height: 46px;
    }

    .userbox .who {
        display: none;
    }
}

/* ---------------------------------------------------------------------
   Каркас страниц
   --------------------------------------------------------------------- */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px var(--gutter) 64px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 24px;
    margin-bottom: 20px;
}

.page-header > :first-child {
    margin-right: auto;
}

.page-sub {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-top: 4px;
}

.panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-top: 3px solid var(--graphite);
    padding: 22px clamp(16px, 2.5vw, 28px);
}

.panel + .panel {
    margin-top: 20px;
}

.panel > h2,
.panel > h3 {
    margin-bottom: 12px;
}

.small-note {
    color: var(--muted);
    font-size: 0.875rem;
    max-width: 75ch;
    margin: 0 0 14px;
}

.empty {
    color: var(--muted);
    padding: 28px 12px;
    text-align: center;
}

/* ---------------------------------------------------------------------
   Кнопки
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 0;
    font: inherit;
    font-weight: 700;
    font-size: 0.9375rem;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-primary {
    background: var(--cyan);
    color: var(--graphite-deep);
}

.btn-primary:hover {
    background: #19cfe2;
}

.btn-dark {
    background: var(--graphite);
    color: var(--white);
}

.btn-dark:hover {
    background: var(--graphite-deep);
}

.btn-secondary {
    background: var(--white);
    color: var(--graphite);
    border-color: var(--line-strong);
}

.btn-secondary:hover {
    border-color: var(--graphite);
}

.btn-ghost {
    background: transparent;
    color: var(--graphite);
    border-color: transparent;
    padding: 0 10px;
}

.btn-ghost:hover {
    color: var(--cyan-ink);
}

.btn-danger {
    background: var(--white);
    color: var(--magenta);
    border-color: #e6aabd;
}

.btn-danger:hover {
    background: var(--magenta);
    color: var(--white);
    border-color: var(--magenta);
}

.btn-small {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.875rem;
}

.btn-full {
    width: 100%;
}

.btn[aria-disabled="true"] {
    opacity: 0.4;
    pointer-events: none;
}

/* ---------------------------------------------------------------------
   Поля ввода
   --------------------------------------------------------------------- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 0;
    background: var(--white);
    color: var(--ink);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

input:hover,
select:hover {
    border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: var(--focus);
}

input:disabled {
    background: var(--paper);
    color: var(--muted);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--cyan-ink);
    margin: 0;
    flex-shrink: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > label,
.field-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--graphite);
}

.field .unit {
    font-weight: 400;
    color: var(--muted);
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9375rem;
    cursor: pointer;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px 20px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.form-inline input[type="text"],
.form-inline input[type="password"] {
    width: auto;
    flex: 1 1 180px;
}

.inline-form {
    display: inline;
}

/* ---------------------------------------------------------------------
   Сообщения
   --------------------------------------------------------------------- */
.flash-container {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
}

.flash {
    padding: 12px 16px;
    border-left: 4px solid var(--cyan);
    background: var(--white);
    border-top: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}

.flash-danger {
    border-left-color: var(--magenta);
    background: var(--magenta-wash);
}

.form-error {
    display: none;
    padding: 10px 14px;
    background: var(--magenta-wash);
    border-left: 4px solid var(--magenta);
    color: #8f1f45;
    font-weight: 600;
    font-size: 0.9375rem;
}

.form-error.is-visible {
    display: block;
}

.is-invalid {
    border-color: var(--magenta) !important;
}

/* ---------------------------------------------------------------------
   Вход
   --------------------------------------------------------------------- */
.login-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
}

.login-aside {
    background: var(--graphite);
    color: #c7d0d8;
    padding: clamp(28px, 6vw, 72px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    position: relative;
    overflow: hidden;
}

.login-logo {
    display: block;
    height: 30px;
    width: auto;
    align-self: flex-start;
}

.login-aside .wordmark {
    color: var(--white);
    font-size: 1.5rem;
}

.login-aside h1 {
    color: var(--white);
    font-size: clamp(1.75rem, 3.4vw, 2.75rem);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.01em;
    max-width: 14ch;
    margin-bottom: 14px;
}

.login-aside p {
    max-width: 42ch;
    margin: 0;
}

.login-main {
    background: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(28px, 5vw, 56px);
}

.login-main h2 {
    margin-bottom: 20px;
}

.login-main form {
    display: grid;
    gap: 16px;
}

@media (max-width: 760px) {
    .login-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .login-aside {
        gap: 18px;
    }

    .login-aside .flow {
        display: none;
    }
}

/* ---------------------------------------------------------------------
   Схема процесса: РК → С1 → С2
   Главный узнаваемый элемент: путь CO₂ через экстрактор и сепараторы.
   --------------------------------------------------------------------- */
.flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    position: relative;
}

.flow::before {
    /* линия трубопровода */
    content: "";
    position: absolute;
    left: calc(100% / 6);
    right: calc(100% / 6);
    top: 15px;
    height: 2px;
    background: var(--cyan);
}

.flow-step {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 0 8px;
}

.flow-node {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: var(--graphite);
    color: var(--white);
    border: 2px solid var(--cyan);
    font-weight: 800;
    font-size: 0.75rem;
    position: relative;
    z-index: 1;
}

.flow-step + .flow-step .flow-node::before {
    /* стрелка направления потока */
    content: "";
    position: absolute;
    left: -9px;
    top: 50%;
    border: 5px solid transparent;
    border-left: 6px solid var(--cyan);
    border-right: 0;
    transform: translateY(-50%);
}

.flow-name {
    font-weight: 800;
    color: var(--graphite);
    font-size: 0.9375rem;
}

.flow-name small {
    display: block;
    font-weight: 400;
    color: var(--muted);
    font-size: 0.8125rem;
}

.flow-inputs {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 200px;
    text-align: left;
}

/* схема на тёмном фоне (страница входа) */
.login-aside .flow-node {
    background: var(--graphite-deep);
}

.login-aside .flow-name {
    color: var(--white);
}

.login-aside .flow-name small {
    color: #9aa6b1;
}

/* компактная схема в строке журнала */
.mode {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 0 14px;
    white-space: nowrap;
}

.mode span {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.mode b {
    font-size: 0.6875rem;
    font-weight: 800;
    color: var(--cyan-ink);
}

/* ---------------------------------------------------------------------
   Главная
   --------------------------------------------------------------------- */
.hero {
    background: var(--graphite);
    color: #c7d0d8;
    padding: clamp(24px, 4vw, 44px) clamp(20px, 4vw, 44px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 28px 40px;
    align-items: end;
}

.hero .page-title {
    color: var(--white);
    font-size: var(--step-3);
}

.hero p {
    margin: 8px 0 0;
    max-width: 50ch;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-actions .btn {
    min-height: 52px;
    padding: 0 26px;
    font-size: 1rem;
}

.hero-actions .btn-secondary {
    background: transparent;
    color: var(--white);
    border-color: #6b7884;
}

.hero-actions .btn-secondary:hover {
    border-color: var(--white);
}

.readouts {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid #4a5763;
    padding-top: 22px;
    gap: 16px;
}

.readout {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.readout dt {
    font-size: 0.875rem;
}

.readout dd {
    margin: 0;
    color: var(--white);
    font-weight: 800;
    font-stretch: 87%;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    line-height: 1.1;
}

.readout dd small {
    font-size: 0.5em;
    font-weight: 600;
    color: var(--cyan);
    margin-left: 4px;
    font-stretch: 100%;
}

@media (max-width: 760px) {
    .hero {
        grid-template-columns: 1fr;
    }

    .readouts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-actions .btn {
        flex: 1 1 auto;
    }
}

.recent {
    margin-top: 28px;
}

.recent-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--white);
    border: 1px solid var(--line);
}

.recent-list li {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto auto;
    gap: 6px 20px;
    align-items: center;
    padding: 12px 18px;
    border-top: 1px solid var(--line);
}

.recent-list li:first-child {
    border-top: 0;
}

.recent-id {
    font-weight: 800;
    color: var(--muted);
}

.recent-main strong {
    display: block;
    color: var(--graphite);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-main span,
.recent-when {
    font-size: 0.875rem;
    color: var(--muted);
}

.recent-yield {
    font-weight: 800;
    color: var(--graphite);
    text-align: right;
}

.recent-yield small {
    display: block;
    font-weight: 600;
    color: var(--cyan-ink);
}

@media (max-width: 600px) {
    .recent-list li {
        grid-template-columns: 40px minmax(0, 1fr) auto;
    }

    .recent-when {
        display: none;
    }
}

/* ---------------------------------------------------------------------
   Журнал
   --------------------------------------------------------------------- */
.journal-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.journal-tools input[type="search"] {
    width: min(340px, 100%);
}

.table-wrapper {
    background: var(--white);
    border: 1px solid var(--line);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.data-table th {
    background: var(--graphite);
    color: var(--white);
    font-size: 0.8125rem;
    font-weight: 700;
    text-align: left;
    padding: 10px 12px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th small {
    display: block;
    font-weight: 400;
    color: #aeb8c1;
}

.data-table td {
    padding: 12px;
    border-top: 1px solid var(--line);
    vertical-align: top;
}

.data-table tbody tr:hover td {
    background: #f4fcfd;
}

.data-table .num {
    text-align: right;
    white-space: nowrap;
}

.cell-id {
    font-weight: 800;
    color: var(--muted);
}

.cell-material strong {
    display: block;
    color: var(--graphite);
    min-width: 12ch;
}

.cell-material span,
.cell-date span {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted);
}

.cell-date {
    white-space: nowrap;
}

.yield {
    min-width: 96px;
    white-space: nowrap;
}

.yield-g {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted);
}

.yield strong {
    font-size: 1.0625rem;
    color: var(--graphite);
}

.yield-bar {
    display: block;
    height: 4px;
    background: var(--paper);
    margin-top: 6px;
}

.yield-bar i {
    display: block;
    height: 100%;
    background: var(--cyan);
}

.row-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.row-links {
    display: flex;
    gap: 14px;
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
}

.row-links a {
    text-decoration: none;
}

.row-links a:hover,
.row-links .link-btn:hover {
    text-decoration: underline;
}

.link-danger {
    color: var(--magenta);
    text-decoration: none;
}

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: 700;
    color: var(--cyan-ink);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.data-table.small th,
.data-table.small td {
    padding: 8px 10px;
}

.no-results {
    display: none;
}

/* Журнал на телефоне: строки превращаются в карточки */
@media (max-width: 900px) {
    .journal-table {
        background: none;
        border: 0;
        overflow: visible;
    }

    .journal-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .journal-table tbody,
    .journal-table tr,
    .journal-table td {
        display: block;
    }

    .journal-table tr {
        background: var(--white);
        border: 1px solid var(--line);
        border-top: 3px solid var(--graphite);
        margin-bottom: 14px;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .journal-table td {
        border-top: 1px solid var(--line);
        padding: 10px 14px;
    }

    .journal-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        color: var(--muted);
        margin-bottom: 2px;
    }

    .journal-table .data-table .num,
    .journal-table td.num {
        text-align: left;
    }

    .journal-table .cell-material,
    .journal-table .cell-mode,
    .journal-table .cell-actions {
        grid-column: 1 / -1;
    }

    /* порядок в карточке: пары «загрузка+время», «С1/С2+выход», «сливы+оператор» */
    .journal-table td:nth-child(1) { order: 1; }
    .journal-table td:nth-child(2) { order: 2; }
    .journal-table td:nth-child(3) { order: 3; }
    .journal-table td:nth-child(4) { order: 4; }
    .journal-table td:nth-child(6) { order: 5; }
    .journal-table td:nth-child(7) { order: 6; }
    .journal-table td:nth-child(8) { order: 7; }
    .journal-table td:nth-child(9) { order: 8; }
    .journal-table td:nth-child(10) { order: 9; }
    .journal-table td:nth-child(5) { order: 10; }
    .journal-table td:nth-child(11) { order: 11; }

    .journal-table .row-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 18px;
    }

    .journal-table .cell-id {
        border-top: 0;
        grid-column: 1;
    }

    .journal-table .cell-date {
        border-top: 0;
    }

    .journal-table .empty {
        grid-column: 1 / -1;
    }

    .row-actions {
        min-width: 0;
    }
}

/* ---------------------------------------------------------------------
   Диалоги
   --------------------------------------------------------------------- */
.modal {
    border: 0;
    padding: 0;
    width: min(960px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    background: var(--white);
    color: var(--ink);
    border-top: 4px solid var(--cyan);
    box-shadow: 0 24px 60px rgba(37, 46, 54, 0.35);
}

.modal-small {
    width: min(560px, calc(100vw - 24px));
}

.modal::backdrop {
    background: rgba(37, 46, 54, 0.55);
}

.modal[open] {
    animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.modal-content {
    padding: 24px clamp(16px, 3vw, 32px) 0;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-close {
    width: 40px;
    height: 40px;
    border: 0;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--graphite);
}

.form-section {
    padding: 18px 0;
    border-top: 1px solid var(--line);
}

.form-section > h3 {
    margin-bottom: 14px;
}

.modal-actions {
    position: sticky;
    bottom: 0;
    background: var(--white);
    border-top: 1px solid var(--line);
    margin: 0 calc(-1 * clamp(16px, 3vw, 32px));
    padding: 14px clamp(16px, 3vw, 32px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.totals {
    display: flex;
    gap: 24px;
    margin-right: auto;
    font-size: 0.875rem;
    color: var(--muted);
}

.totals strong {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--graphite);
    font-stretch: 87%;
}

/* Сливы */
.sliv-table {
    display: grid;
    gap: 8px;
}

.sliv-row {
    display: grid;
    grid-template-columns: 36px repeat(3, minmax(0, 1fr)) 44px;
    gap: 10px;
    align-items: center;
}

.sliv-row.is-head {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--muted);
}

.sliv-n {
    font-weight: 800;
    color: var(--muted);
    text-align: center;
}

.sliv-remove {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line-strong);
    background: var(--white);
    color: var(--muted);
    font-size: 1.25rem;
    cursor: pointer;
}

.sliv-remove:hover {
    color: var(--magenta);
    border-color: var(--magenta);
}

.sliv-add {
    margin-top: 10px;
}

.slivs-table {
    width: 100%;
    border-collapse: collapse;
}

.slivs-table th,
.slivs-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    text-align: right;
}

.slivs-table th:first-child,
.slivs-table td:first-child {
    text-align: left;
}

.slivs-table th {
    font-size: 0.8125rem;
    color: var(--muted);
}

@media (max-width: 600px) {
    .flow {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .flow::before {
        display: none;
    }

    .flow-step:not(:last-child)::after {
        content: "";
        position: absolute;
        left: 15px;
        top: 32px;
        bottom: -18px;
        width: 2px;
        background: var(--cyan);
    }

    .flow-step {
        display: grid;
        grid-template-columns: 32px minmax(0, 1fr);
        align-items: start;
        text-align: left;
        gap: 6px 14px;
        padding: 0;
    }

    .flow-step + .flow-step .flow-node::before {
        left: 50%;
        top: -9px;
        border: 5px solid transparent;
        border-top: 6px solid var(--cyan);
        border-bottom: 0;
        transform: translateX(-50%);
    }

    .flow-inputs {
        grid-column: 2;
        max-width: none;
        grid-template-columns: 1fr 1fr;
    }

    .sliv-row {
        grid-template-columns: 24px repeat(3, minmax(0, 1fr)) 44px;
        gap: 6px;
    }

    .totals {
        width: 100%;
    }
}

/* ---------------------------------------------------------------------
   Настройки
   --------------------------------------------------------------------- */
.subnav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    background: var(--paper);
    z-index: 5;
}

.subnav a {
    padding: 10px 14px;
    color: var(--graphite);
    font-weight: 700;
    font-size: 0.9375rem;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.subnav a:hover {
    border-bottom-color: var(--cyan);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.settings-section {
    background: var(--white);
    border: 1px solid var(--line);
    border-top: 3px solid var(--graphite);
    padding: 22px clamp(16px, 2.5vw, 28px);
    min-width: 0;
    scroll-margin-top: 60px;
}

.settings-section > h3 {
    font-size: var(--step-1);
    margin-bottom: 10px;
}

.settings-section h4 {
    font-size: 1rem;
    margin: 22px 0 10px;
}

@media (max-width: 1000px) {
    .settings-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.user-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--line);
}

.user-list > li {
    border-bottom: 1px solid var(--line);
}

.user-list summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
    list-style: none;
}

.user-list summary::-webkit-details-marker {
    display: none;
}

.user-list summary::after {
    content: "Изменить";
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--cyan-ink);
}

.user-list details[open] summary::after {
    content: "Свернуть";
}

.user-name {
    font-weight: 700;
    color: var(--graphite);
}

.badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--cyan-wash);
    color: var(--cyan-ink);
}

.badge-muted {
    background: var(--paper);
    color: var(--muted);
}

.user-edit {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 4px 0 16px;
}

.user-edit .wide {
    grid-column: 1 / -1;
}

.simple-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    border-top: 1px solid var(--line);
}

.simple-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}

.fieldset {
    border: 1px solid var(--line);
    margin: 0;
    padding: 12px 16px 16px;
    min-width: 0;
}

.fieldset legend {
    font-weight: 800;
    color: var(--graphite);
    padding: 0 6px;
    font-size: 0.9375rem;
}

.checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px 16px;
}

.form-card {
    display: grid;
    gap: 16px;
}

.form-card > label:not(.checkbox-inline) {
    display: grid;
    gap: 6px;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--graphite);
}

.help-block {
    margin-top: 18px;
    font-size: 0.9375rem;
}

.help-block ol,
.help-block ul {
    padding-left: 1.25rem;
    margin: 8px 0 0;
}

.help-block li {
    margin-bottom: 6px;
    max-width: 75ch;
}

/* ---------------------------------------------------------------------
   Редактор этикетки
   --------------------------------------------------------------------- */
.label-section {
    grid-column: 1 / -1;
}

.label-editor {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr);
    gap: 24px;
    margin-top: 8px;
}

@media (max-width: 1000px) {
    .label-editor {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (min-width: 1001px) {
    .label-canvas-col {
        position: sticky;
        top: 60px;
        align-self: start;
    }
}

.label-canvas-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.label-canvas-toolbar .small-note {
    margin: 0;
}

.label-canvas-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background-color: #e9ecee;
    background-image: radial-gradient(#c9ced3 1px, transparent 1px);
    background-size: 14px 14px;
    border: 1px solid var(--line);
    min-height: 220px;
    overflow: auto;
}

.label-canvas {
    position: relative;
    background-color: #fff;
    color: #000;
    font-family: "LblDejaVu", "DejaVu Sans", Verdana, sans-serif;
    box-shadow: 0 1px 2px rgba(37, 46, 54, 0.2), 0 10px 24px rgba(37, 46, 54, 0.18);
    outline: none;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
}

.label-canvas:focus-visible {
    box-shadow: var(--focus);
}

.label-canvas.with-grid {
    background-image:
        linear-gradient(to right, rgba(0, 128, 142, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 128, 142, 0.1) 1px, transparent 1px);
}

.label-canvas.with-border::after {
    content: "";
    position: absolute;
    inset: 0.75mm;
    border: 1px solid #000;
    border-radius: 3px;
    pointer-events: none;
}

.label-size-caption {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--muted);
    margin-top: 8px;
}

.lbl-el {
    position: absolute;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: move;
    outline: 1px dashed transparent;
}

.lbl-el:hover {
    outline-color: rgba(0, 128, 142, 0.6);
}

.lbl-el.is-selected {
    outline: 1px solid var(--cyan);
    background: rgba(0, 193, 213, 0.1);
}

.lbl-el.is-disabled {
    display: none;
}

.lbl-el.lbl-multiline {
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
}

.lbl-line {
    background: #000;
}

.lbl-qr {
    background: conic-gradient(#000 25%, #fff 0 50%, #000 0 75%, #fff 0) 0 0 / 20% 20%;
    border: 2px solid #000;
    opacity: 0.85;
}

.label-fieldset {
    display: block;
    margin-bottom: 14px;
}

.label-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
}

.lbl-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--graphite);
    min-width: 0;
}

.lbl-field input,
.lbl-field select {
    min-height: 38px;
    padding: 6px 10px;
    font-weight: 400;
}

.lbl-wide {
    grid-column: 1 / -1;
}

.label-el-list {
    list-style: none;
    padding: 0;
    margin: 0 0 10px;
    max-height: 280px;
    overflow-y: auto;
    border-top: 1px solid var(--line);
}

.label-el-list li {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.875rem;
    cursor: pointer;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
}

.label-el-list li:hover {
    background: #f4fcfd;
}

.label-el-list li.is-selected {
    background: var(--cyan-wash);
    border-left-color: var(--cyan);
}

.label-el-list li.is-disabled .lbl-li-name {
    opacity: 0.5;
    text-decoration: line-through;
}

.lbl-li-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.lbl-li-pos {
    font-size: 0.75rem;
    color: var(--muted);
}

.lbl-li-btn {
    border: 1px solid var(--line-strong);
    background: var(--white);
    color: var(--graphite);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.8125rem;
}

.lbl-li-btn:hover {
    border-color: var(--graphite);
}

.lbl-li-btn[data-act="del"]:hover {
    color: var(--magenta);
    border-color: var(--magenta);
}

.label-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.label-add-row select {
    flex: 1 1 200px;
    width: auto;
    min-height: 34px;
    padding: 4px 10px;
}

.label-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.label-actions select {
    width: auto;
    min-height: 34px;
    padding: 4px 10px;
}

.label-reset-form {
    margin-top: 10px;
}

/* ---------------------------------------------------------------------
   Доступность
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

[hidden] {
    display: none !important;
}

.row-links .link-btn {
    text-decoration: none;
    font-size: inherit;
}

.journal-tools {
    flex-wrap: nowrap;
}

@media (max-width: 600px) {
    .journal-tools {
        flex-wrap: wrap;
        width: 100%;
    }
}

.modal-actions {
    z-index: 2;
}
