/* ==========================================================================
   База специалистов и оборудования
   Оформление по образцу заказчика: светло-голубой фон, белая карточка-страница,
   тонкая верхняя полоса, шапка с логотипом и синей кнопкой выхода.
   ========================================================================== */

:root {
    --bg-top: #e6effa;
    --bg-bottom: #f4f8fd;
    --surface: #ffffff;
    --surface-2: #f7f9fc;

    --line: #e4e9f0;
    --line-soft: #eef1f6;
    --line-strong: #d2d9e4;

    --ink: #16202e;
    --ink-2: #55637a;
    --ink-3: #8e99ab;

    --accent: #2b7fff;
    --accent-dark: #1a63d8;
    --accent-soft: #eaf2ff;
    --brand-red: #9e1b1b;

    --danger: #c0392b;
    --danger-soft: #fdf1f0;
    --ok: #12805c;
    --ok-soft: #e8f8f1;
    --warn: #b06f10;
    --warn-soft: #fdf6e6;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 20px;
    --r-xl: 26px;

    --shadow-sm: 0 1px 2px rgba(22, 40, 70, .05);
    --shadow-card: 0 10px 40px rgba(30, 60, 110, .08);
    --shadow-lg: 0 24px 70px rgba(20, 40, 80, .22);

    /* Чёрные полосы сверху и снизу */
    --bar-bg: #0b0d10;
    --stamp-ink: #1b3a5f;
    --mono: "Consolas", "SF Mono", "DejaVu Sans Mono", "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 420px) fixed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }

.site { display: flex; flex-direction: column; min-height: 100vh; }
.container { width: 100%; max-width: 1560px; margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 21px; line-height: 1.3; }
h2 { font-size: 15px; margin: 26px 0 12px; }
h3 { font-size: 13px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-2); }
.error { display: block; color: var(--danger); font-size: 12px; }
.req { color: var(--danger); font-weight: 400; }

/* --------------------------------------------------------------------------
   Верхняя полоса
   -------------------------------------------------------------------------- */
.topbar {
    background: var(--bar-bg);
    color: #b9c1cc;
    font-size: 12px;
}
.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    min-height: 36px;
    flex-wrap: wrap;
}
.topbar__left { min-width: 0; overflow-wrap: anywhere; }
.topbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar__link { color: #e6eaef; }
.topbar__link:hover { color: #fff; }
.topbar__divider { width: 1px; height: 12px; background: rgba(255, 255, 255, .22); }

/* --------------------------------------------------------------------------
   Шапка
   -------------------------------------------------------------------------- */
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead__inner {
    display: flex;
    align-items: center;
    gap: 26px;
    min-height: 104px;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__logo {
    height: 68px;
    width: auto;
    max-width: 170px;
    object-fit: contain;
    flex: none;
}
.brand__title {
    max-width: 260px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -.01em;
}

.mainnav { display: flex; align-items: center; gap: 6px; flex: 1; flex-wrap: wrap; }
.mainnav__link {
    padding: 8px 12px;
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: 14px;
    white-space: nowrap;
}
.mainnav__link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.mainnav__link.is-active { color: var(--ink); font-weight: 600; }

.userbox { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.userbox__person { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.userbox__person:hover { text-decoration: none; color: var(--ink); }
.userbox__avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 700;
}
.userbox__name { font-size: 13px; }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    margin-left: auto;
    background: none;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    cursor: pointer;
}
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--ink); }

/* --------------------------------------------------------------------------
   Страница-карточка
   -------------------------------------------------------------------------- */
.page { flex: 1; padding: 26px 0 40px; }
.page-card {
    padding: 28px 30px 32px;
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card);
}

.site-footer {
    padding: 20px 0;
    margin-top: auto;
    background: var(--bar-bg);
    color: #9aa3ae;
    font-size: 12px;
}
.site-footer__inner { display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.site-footer .muted { color: #7d8794; }

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.page-head .muted { font-size: 13px; }

/* Заголовок таблицы: название, поиск, фильтр, шестерёнка */
.card-head {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.card-head__title { flex: 0 0 auto; font-size: 19px; margin-right: 4px; }
.card-head__search { display: flex; gap: 8px; flex: 1 1 300px; min-width: 220px; }
.card-head__search .field-input { flex: 1; min-width: 0; }
.card-head__tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    flex-wrap: wrap;
    margin-left: auto;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    color: var(--ink-2);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 19px; height: 19px; }

/* --------------------------------------------------------------------------
   Сообщения и подсказки
   -------------------------------------------------------------------------- */
.messages { list-style: none; margin: 0 0 18px; padding: 0; }
.messages__item {
    padding: 12px 18px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ink-3);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
}
.messages__item--success { border-left-color: var(--ok); background: var(--ok-soft); border-color: #c6ecdd; }
.messages__item--error { border-left-color: var(--danger); background: var(--danger-soft); border-color: #f2d3cf; }
.messages__item--warning { border-left-color: var(--warn); background: var(--warn-soft); border-color: #f0e0bb; }

.notice {
    padding: 14px 18px;
    margin-bottom: 20px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink-2);
    font-size: 13px;
}
.hint { margin: 0 0 16px; color: var(--ink-3); font-size: 12px; }

/* --------------------------------------------------------------------------
   Главная
   -------------------------------------------------------------------------- */
.home__title { font-size: 25px; margin-bottom: 6px; }
.home__section { margin-top: 28px; }
.home__admin { display: flex; gap: 8px; margin-top: 32px; flex-wrap: wrap; }

.section-label {
    margin: 0 0 12px;
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tiles--wide { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }

.tile {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink);
    transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.tile:hover {
    text-decoration: none;
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(43, 127, 255, .12);
    transform: translateY(-1px);
}
.tile--doc { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
.tile--muted { opacity: .55; }
.tile__link { display: flex; flex-direction: column; gap: 3px; color: var(--ink); min-width: 0; }
.tile__link:hover { text-decoration: none; }
.tile__name { font-weight: 600; font-size: 14px; }
.tile__meta { display: flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 12px; }

.dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #ccd4e0; }
.dot--on { background: var(--ok); }

/* --------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 15px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover { background: #2b384d; border-color: #2b384d; color: #fff; }

.btn--accent {
    padding: 9px 20px;
    background: var(--accent);
    border-color: var(--accent);
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
}
.btn--accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn--danger { border-color: #e8c6c1; color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn--tiny { padding: 4px 10px; font-size: 12px; }

.btn--link {
    padding: 4px 6px;
    background: none;
    border-color: transparent;
    color: var(--ink-3);
    font-size: 16px;
}
.btn--link:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.toolbar--search { margin-bottom: 12px; }
.toolbar--search .field-input { min-width: 320px; flex: 0 1 420px; }
.toolbar__sep {
    flex: none;
    align-self: stretch;
    width: 1px;
    min-height: 22px;
    margin: 0 6px;
    background: var(--line);
}
.inline-form { display: inline-flex; margin: 0; }

/* --------------------------------------------------------------------------
   Поля и формы
   -------------------------------------------------------------------------- */
.field-input {
    width: 100%;
    padding: 9px 13px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.field-input::placeholder { color: var(--ink-3); }
.field-input:hover { border-color: var(--ink-3); }
.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-input--narrow { width: auto; min-width: 138px; }
select.field-input { cursor: pointer; }
textarea.field-input { resize: vertical; min-height: 70px; }

.field-checkbox { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.card {
    padding: 22px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}
.card h2:first-child { margin-top: 0; }

/* Анкета разбита на смысловые блоки: «Специалист», «Документы», «Работа» */
.form-block { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line-soft); }
.form-block:first-of-type { padding-top: 0; margin-top: 0; border-top: 0; }
.form-block__title {
    margin: 0 0 12px;
    color: var(--ink-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 18px; }
.form-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-field label { color: var(--ink-2); font-size: 12px; font-weight: 600; }
.form-field small { font-size: 11px; line-height: 1.4; }
.form-field--error .field-input { border-color: var(--danger); }
.form-field:has(textarea) { grid-column: 1 / -1; }
.form-field:has(.checkgrid) { grid-column: 1 / -1; }

/* Список галочек: колонки, аккуратный висячий отступ и прокрутка */
.checkgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2px 18px;
    max-height: 360px;
    overflow-y: auto;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}
.checkgrid::-webkit-scrollbar {
    width: 8px;
}
.checkgrid::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-radius: 4px;
}
.checkgrid::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 4px;
}
.checkgrid::-webkit-scrollbar-thumb:hover {
    background: var(--ink-3);
}
.checkgrid > div { min-width: 0; }
.checkgrid label {
    display: block;
    padding: 7px 6px 7px 28px;
    text-indent: -28px;
    border-radius: 6px;
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
}
.checkgrid label:hover { background: var(--accent-soft); }
.checkgrid input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0 11px 0 0;
    accent-color: var(--accent);
    vertical-align: -2px;
    cursor: pointer;
}

/* Django CheckboxSelectMultiple обертка */
.checkgrid > #id_instructions.field-checkbox {
    display: contents !important;
    width: auto !important;
    height: auto !important;
}
.checkgrid > #id_instructions.field-checkbox > div {
    min-width: 0;
}
/* Галочка стоит рядом с подписью, а не под ней */
.form-field:has(> input[type="checkbox"]) {
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-end;
    align-self: end;
    gap: 10px;
    padding-bottom: 9px;
}
.form-field:has(> input[type="checkbox"]) label {
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
}
/* Старая разметка списка галочек (на случай кастомных виджетов) */
.form-field ul { margin: 0; padding: 0; list-style: none; }

.form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
}
.form-errors {
    padding: 12px 16px;
    margin-bottom: 18px;
    background: var(--danger-soft);
    border: 1px solid #f2d3cf;
    border-radius: var(--r-md);
    color: var(--danger);
    font-size: 13px;
}

.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin: 14px 0 18px; }
.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 13px;
    cursor: pointer;
}
.checkbox-list label:hover { background: var(--surface-2); border-color: var(--line-strong); }
.plain-list { margin: 0 0 16px; padding-left: 18px; color: var(--ink-2); font-size: 13px; }

/* --------------------------------------------------------------------------
   Таблицы
   -------------------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background:
        linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) left center,
        linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) right center,
        radial-gradient(farthest-side at 0 50%, rgba(22, 40, 70, .09), rgba(22, 40, 70, 0)) left center,
        radial-gradient(farthest-side at 100% 50%, rgba(22, 40, 70, .09), rgba(22, 40, 70, 0)) right center;
    background-color: var(--surface);
    background-repeat: no-repeat;
    background-size: 44px 100%, 44px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
}

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}
.data-table thead th + th { border-left: 1px solid var(--line-soft); }

.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}
.data-table tbody td + td { border-left: 1px solid var(--line-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }

/* Строка-заголовок группы оборудования — как в образце МТБ */
.data-table tbody tr.group-row td {
    padding: 10px 14px;
    background: #eef2f8;
    border-left: 0;
    color: var(--ink);
    font-weight: 700;
    text-align: center;
}
.data-table tbody tr.group-row:hover td { background: #eef2f8; }

/* Найденная строка: жирный шрифт и светло-зелёная заливка */
.data-table tbody tr.row--matched td,
.data-table tbody tr.row--matched:hover td {
    background: var(--ok-soft);
    font-weight: 600;
}
.data-table tbody tr.row--expired td { background: var(--warn-soft); }

.col-check { width: 44px; text-align: center; }
.col-sm { min-width: 96px; }
.col-md { min-width: 150px; }
.col-lg { min-width: 230px; }
.col-xl { min-width: 340px; }

/* Кнопки строки не должны вставать лесенкой — колонка под них фиксированная */
.col-actions { width: 184px; min-width: 184px; }
.row-actions { display: flex; align-items: flex-start; gap: 6px; flex-wrap: nowrap; }
.row-actions .btn { white-space: nowrap; }
.empty-row { padding: 48px 14px !important; color: var(--ink-3); text-align: center !important; }

.mini-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.mini-table th, .mini-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: top;
}
.mini-table th { width: 38%; color: var(--ink-2); font-weight: 600; }
.mini-table tr:last-child th, .mini-table tr:last-child td { border-bottom: 0; }

.pagination { display: flex; align-items: center; gap: 14px; margin-top: 16px; font-size: 13px; }
.pagination a { color: var(--ink-2); }
.pagination a:hover { color: var(--accent); }
.pagination__current { color: var(--ink-3); }

.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill--on { background: var(--ok-soft); color: var(--ok); }
.pill--off { background: #eef1f6; color: var(--ink-2); }
.journal-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.journal-title { letter-spacing: -.01em; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge--admin { background: var(--warn-soft); color: var(--warn); }
.badge--manager { background: var(--accent-soft); color: var(--accent-dark); }

/* --------------------------------------------------------------------------
   Штамп электронной подписи
   -------------------------------------------------------------------------- */
.stamp {
    display: inline-block;
    min-width: 288px;
    max-width: 360px;
    padding: 7px 10px 8px;
    background: #fff;
    border: 2px solid var(--stamp-ink);
    border-radius: 8px;
    color: var(--stamp-ink);
    font-family: var(--mono);
    line-height: 1.35;
}
.stamp__line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1.5px solid var(--stamp-ink);
    font-size: 10px;
}
.stamp__line--head { font-size: 10px; }
.stamp__fio { font-weight: 700; letter-spacing: 0; }
.stamp__time, .stamp__alg { white-space: nowrap; letter-spacing: .02em; }
.stamp__sign { font-weight: 700; letter-spacing: .02em; }
.stamp__hash {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* «размер в 2 раза меньше» — по инструкции заказчика */
    font-size: 5.5px;
    letter-spacing: .06em;
}
.stamp--expired { border-color: var(--warn); color: var(--warn); }
.stamp--expired .stamp__line { border-bottom-color: var(--warn); }
.stamp__warning { margin-top: 3px; font-weight: 700; font-size: 8px; }

.signature-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* --------------------------------------------------------------------------
   Протокол, QR, PDF
   -------------------------------------------------------------------------- */
/* Протокол проверки оборудования — вид как у бумажного бланка */
.protocol { max-width: 940px; margin: 0 auto; }
.protocol__org { text-align: center; font-weight: 700; text-decoration: underline; }
.protocol__title { margin: 14px 0 4px; font-size: 17px; text-align: center; }
.protocol__subtitle { margin: 0 0 20px; font-weight: 600; text-align: center; }
.protocol__place {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
.protocol__group { margin: 16px 0 8px; font-size: 14px; }
.protocol__member { padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.protocol__member small { display: block; font-size: 10px; }
.protocol__facts { margin: 22px 0; }
.protocol__facts > div { display: flex; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.protocol__facts dt { margin: 0; color: var(--ink-2); min-width: 240px; }
.protocol__facts dd { margin: 0; font-weight: 500; }
.protocol__signatures { margin-top: 26px; }
.protocol__sign-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
}
.protocol__sign-role { min-width: 200px; font-weight: 600; }
.protocol__sign-fio {
    min-width: 190px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--ink);
    text-align: center;
}
.protocol__sign-fio small { display: block; border-top: 0; font-size: 10px; }
.protocol__qr { margin-top: 26px; text-align: right; }
.protocol .toolbar { margin-top: 26px; margin-bottom: 0; }

.qr-thumb { display: block; width: 60px; height: 60px; }
.qr-large { width: 132px; height: 132px; flex: none; }

.pdf-frame { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); }
.pdf-frame iframe { display: block; width: 100%; height: 74vh; border: 0; }

/* --------------------------------------------------------------------------
   Модальные окна
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 44px 16px;
    overflow-y: auto;
    background: rgba(16, 30, 55, .42);
}
.modal[hidden] { display: none; }
.modal__box {
    width: min(920px, 100%);
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
}
.modal__head h2 { margin: 0; font-size: 16px; }
.modal__body { padding: 24px; }
.modal__body .form-actions { margin-bottom: 0; }
.modal__hint { margin: 14px 0; color: var(--ink-3); font-size: 12px; }
.modal__section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line-soft); }
.modal__section:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
.modal__section h3 { margin-bottom: 10px; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

/* --------------------------------------------------------------------------
   Вход
   -------------------------------------------------------------------------- */
.page-card:has(.login) { max-width: 520px; margin: 4vh auto 0; }
.login { max-width: 400px; margin: 0 auto; }
.login__brand {
    margin-bottom: 20px;
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.login h1 { font-size: 23px; }
.login > .muted { margin-bottom: 22px; font-size: 13px; }
.login .form-grid { grid-template-columns: 1fr; }
.login .btn { width: 100%; }

/* --------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
    .brand__title { max-width: 210px; font-size: 13px; }
    .mainnav__link { padding: 7px 9px; font-size: 13px; }
    .masthead__inner { gap: 18px; }
}

/* ---------- Планшеты и телефоны ---------- */
@media (max-width: 960px) {
    .container { padding: 0 14px; }

    .masthead__inner { min-height: 74px; padding: 12px 0; gap: 12px; }
    .brand { gap: 12px; }
    .brand__logo { height: 52px; max-width: 128px; }
    .brand__title { max-width: none; flex: 1; font-size: 13px; }

    .nav-toggle { display: flex; }
    .mainnav {
        display: none;
        order: 3;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding-top: 8px;
        border-top: 1px solid var(--line);
    }
    .mainnav.is-open { display: flex; }
    .mainnav__link { padding: 11px 12px; font-size: 15px; }
    .userbox {
        justify-content: space-between;
        margin: 10px 0 4px;
        padding-top: 10px;
        border-top: 1px solid var(--line);
    }

    .page { padding: 14px 0 26px; }
    .page-card { padding: 18px 14px 22px; border-radius: var(--r-lg); }

    .card-head { gap: 10px; }
    .card-head__title { flex: 1 1 100%; font-size: 17px; }
    .card-head__search { flex: 1 1 100%; min-width: 0; }
    .card-head__tools { flex: 1 1 100%; justify-content: flex-start; margin-left: 0; }

    .toolbar--search .field-input { min-width: 0; flex: 1 1 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .checkgrid { grid-template-columns: 1fr; max-height: 240px; }
    .tiles, .tiles--wide { grid-template-columns: 1fr; }
    .home__title { font-size: 21px; }

    .modal { padding: 12px 8px 24px; }
    .modal__box { width: 100%; border-radius: var(--r-md); }
    .modal__head { padding: 14px 16px; }
    .modal__body { padding: 16px; }

    .protocol { padding: 0; }
    .protocol__title { font-size: 15px; }
    .protocol__place { flex-direction: column; gap: 4px; }
    .protocol__facts > div { flex-direction: column; gap: 2px; }
    .protocol__facts dt { min-width: 0; }
    .protocol__sign-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .protocol__sign-role { min-width: 0; }
    .protocol__sign-fio { min-width: 0; text-align: left; }
    .protocol__qr { text-align: left; }

    .site-footer__inner { flex-direction: column; }
}

/* ---------- Телефоны ---------- */
@media (max-width: 600px) {
    .container { padding: 0 10px; }
    .page-card { padding: 14px 10px 18px; border-radius: var(--r-md); }

    .topbar { font-size: 11px; }
    .topbar__inner { justify-content: flex-start; }

    .brand__logo { height: 44px; max-width: 104px; }
    .brand__title { font-size: 12px; line-height: 1.25; }

    h1, .card-head__title { font-size: 16px; }
    .home__title { font-size: 19px; }

    /* Кнопки в один столбец, чтобы ничего не съезжало */
    .toolbar { gap: 6px; }
    .toolbar .btn,
    .form-actions .btn,
    .card-head__tools .btn { flex: 1 1 100%; }
    .card-head__search { flex-wrap: wrap; }
    .card-head__search .btn { flex: 1 1 100%; }
    .field-input--narrow { width: 100%; min-width: 0; }
    .toolbar__sep { display: none; }
    .icon-btn { flex: 0 0 auto; }

    .data-table { font-size: 12px; }
    .data-table thead th, .data-table tbody td { padding: 9px 10px; }
    .col-actions { width: 150px; min-width: 150px; }
    .row-actions { flex-wrap: wrap; }
    .row-actions .btn { flex: 1 1 100%; }

    .stamp { min-width: 240px; max-width: 280px; padding: 6px 8px; }
    .stamp__line { font-size: 9px; }
    .stamp__line--head { font-size: 9px; }
    .stamp__hash { font-size: 5px; }

    .pagination { flex-wrap: wrap; gap: 10px; font-size: 12px; }
    .pdf-frame iframe { height: 60vh; }
    .mini-table th { width: 45%; }
    .qr-large { width: 108px; height: 108px; }
}
