/* Стили портала поверх Bootstrap 5.3 */
:root {
    --app-sidebar-width: 250px;
    --app-topbar-height: 56px;
}

html { scrollbar-gutter: stable; }   /* шапка не «прыгает», когда появляется полоса прокрутки */
body { min-height: 100vh; }
[id] { scroll-margin-top: calc(var(--app-topbar-height) + 1rem); }   /* якоря не прячутся под липкой шапкой */

/* ---------- Каркас ---------- */
.app-shell { display: flex; min-height: calc(100vh - var(--app-topbar-height)); }
.app-content { flex: 1; min-width: 0; }

@media (min-width: 992px) {
    .app-sidebar {
        width: var(--app-sidebar-width);
        flex-shrink: 0;
        position: sticky;
        top: var(--app-topbar-height);
        height: calc(100vh - var(--app-topbar-height));
        overflow-y: auto;
        background: var(--bs-body-bg);
    }
}

.app-sidebar .nav-link {
    display: flex; align-items: center; gap: .65rem;
    color: var(--bs-body-color);
    border-radius: .5rem;
    padding: .5rem .75rem;
}
.app-sidebar .nav-link:hover { background: var(--bs-secondary-bg); }
.app-sidebar .nav-link.active { color: #fff; background: var(--bs-primary); }
.app-sidebar .nav-link .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; }

.sidebar-heading {
    font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--bs-secondary-color);
    padding: 1rem .75rem .35rem;
}

.avatar {
    width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bs-primary); color: #fff; font-weight: 600; font-size: .9rem; object-fit: cover;
}
.avatar-xs { width: 1.4rem; height: 1.4rem; font-size: .7rem; }
.avatar-md { width: 2.75rem; height: 2.75rem; font-size: 1.1rem; }
.avatar-lg { width: 5rem; height: 5rem; font-size: 2rem; }

/* ---------- Брендинг ---------- */
.brand-logo { height: 32px; width: auto; max-width: 160px; object-fit: contain; }
.brand-logo-preview { height: 64px; width: auto; max-width: 240px; object-fit: contain; }
.auth-logo-img { max-height: 72px; max-width: 220px; object-fit: contain; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.brand-section { font-size: .95rem; }
.swatch { width: 2rem; height: 2rem; border-radius: 50%; padding: 0; border: 2px solid var(--bs-body-bg); box-shadow: 0 0 0 1px var(--bs-border-color); }
.swatch.active, .swatch:focus-visible { box-shadow: 0 0 0 3px var(--bs-body-color); }
.swatch-0d6efd { background: #0d6efd; }
.swatch-198754 { background: #198754; }
.swatch-6f42c1 { background: #6f42c1; }
.swatch-d63384 { background: #d63384; }
.swatch-dc3545 { background: #dc3545; }
.swatch-fd7e14 { background: #fd7e14; }
.swatch-0b7285 { background: #0b7285; }
.swatch-343a40 { background: #343a40; }

/* ---------- «Кубик»: приложения ---------- */
.launcher { width: min(92vw, 380px); }
.launcher-btn { display: inline-flex; align-items: center; gap: .4rem; border: 0; border-radius: .5rem;
                padding: .35rem .75rem !important; font-weight: 600; line-height: 1.2;
                background: var(--bs-primary); color: #fff !important; box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
.launcher-btn:hover, .launcher-btn:focus-visible, .launcher-btn[aria-expanded="true"] { filter: brightness(1.12); color: #fff !important; }
.launcher-btn .bi { font-size: 1.05rem; }
.launcher-hint { position: absolute; top: calc(100% + .55rem); right: 0; z-index: 1040; width: min(80vw, 260px);
                 background: var(--bs-primary); color: #fff; border-radius: .6rem; padding: .7rem .8rem; font-size: .875rem;
                 box-shadow: var(--bs-box-shadow); }
.launcher-hint::before { content: ''; position: absolute; top: -.4rem; right: 1.2rem; border: .4rem solid transparent; border-top: 0; border-bottom-color: var(--bs-primary); }
.launcher-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.launcher-tile {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center;
    padding: .6rem .25rem; border-radius: .75rem; color: var(--bs-body-color); text-decoration: none; font-size: .8rem; line-height: 1.15;
}
.launcher-tile:hover, .launcher-tile:focus-visible { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.launcher-tile.active { background: var(--bs-primary-bg-subtle); }
.launcher-icon {
    width: 2.75rem; height: 2.75rem; border-radius: .8rem; display: flex; align-items: center; justify-content: center;
    background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); font-size: 1.35rem;
}
.launcher-tile.active .launcher-icon { background: var(--bs-primary); color: #fff; }

/* ---------- Колокольчик ---------- */
.bell-badge { top: .1rem; right: -.1rem; font-size: .62rem; padding: .2em .45em; }
.bell-menu { width: min(94vw, 380px); }
.bell-list { max-height: min(60vh, 460px); overflow-y: auto; }
.bell-item { display: block; padding: .6rem 1rem; color: var(--bs-body-color); text-decoration: none; border-bottom: 1px solid var(--bs-border-color-translucent); }
.bell-item:hover, .bell-item:focus-visible { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.bell-item.unread { background: var(--bs-primary-bg-subtle); }
.bell-row { position: relative; }
.bell-row .bell-item { padding-right: 2.6rem; }
.bell-done { position: absolute; top: .35rem; right: .35rem; width: 2rem; height: 2rem; padding: 0; border-radius: 50%; font-weight: 700; text-decoration: none; color: var(--bs-secondary-color); }
.bell-done:hover, .bell-done:focus-visible { background: var(--bs-body-bg); color: var(--bs-success); }
.bell-item .bell-meta { font-size: .75rem; color: var(--bs-secondary-color); }
.notif-unread { background: var(--bs-primary-bg-subtle); }

/* ---------- Плитки модулей ---------- */
.module-tile { transition: transform .12s ease, box-shadow .12s ease; }
.module-tile:hover { transform: translateY(-2px); box-shadow: var(--bs-box-shadow-sm); }
.module-icon {
    width: 2.75rem; height: 2.75rem; border-radius: .75rem; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis);
    font-size: 1.35rem;
}

/* ---------- Справка ---------- */
.module-icon-sm { width: 2.2rem; height: 2.2rem; font-size: 1.1rem; border-radius: .6rem; }
.help-steps { padding-left: 1.4rem; }
.help-steps li { margin-bottom: .75rem; }
.help-group { font-weight: 600; color: var(--bs-primary); margin-top: 1rem; margin-bottom: .35rem; text-transform: uppercase; font-size: .8rem; letter-spacing: .03em; }
.help-faq details { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .55rem .8rem; margin-bottom: .5rem; background: var(--bs-body-bg); }
.help-faq summary { cursor: pointer; font-weight: 500; }
.help-faq details[open] summary { margin-bottom: .4rem; }
.help-faq details p { margin: 0; color: var(--bs-secondary-color); }

/* ---------- Страница входа ---------- */
.auth-page { background: var(--bs-tertiary-bg); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { font-size: 2.5rem; color: var(--bs-primary); line-height: 1; }

.otp-input { letter-spacing: .35em; font-family: var(--bs-font-monospace); }

/* ---------- Выбор темы ---------- */
.theme-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.theme-option { display: inline-flex; align-items: center; gap: .5rem; }
.theme-swatch { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid var(--bs-border-color); }
.theme-swatch-light { background: #fff; }
.theme-swatch-dark  { background: #212529; }
.theme-swatch-auto  { background: linear-gradient(135deg, #fff 50%, #212529 50%); }

/* ---------- 2FA ---------- */
.qr-box { min-height: 200px; display: flex; align-items: center; justify-content: center; }
.qr-box img, .qr-box canvas { background: #fff; padding: 8px; border-radius: .5rem; }
.codes-card { max-width: 28rem; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem 1.5rem; font-size: 1.05rem; }

/* ---------- Админка ---------- */
.generated-password { max-width: 22rem; }
.audit-details { max-width: 28rem; }
.table > :not(caption) > * > * { vertical-align: middle; }

/* ---------- Устройства ---------- */
.status-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.status-dot.online  { background: var(--bs-success); box-shadow: 0 0 0 3px var(--bs-success-bg-subtle); }
.status-dot.offline { background: var(--bs-secondary-color); opacity: .5; }
.form-narrow { max-width: 40rem; }
.data-preview { max-width: 32rem; }
.json-view {
    background: var(--bs-tertiary-bg); border-radius: .5rem; padding: .75rem 1rem;
    max-height: 70vh; overflow: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Модуль OWA MOS ---------- */
.ow-table td { font-size: .9rem; }
.ow-table .ow-check { width: 2rem; }
.ow-muted td { opacity: .6; }
.ow-kv th { width: 38%; font-weight: 500; color: var(--bs-secondary-color); font-size: .88rem; }

/* ---------- Публичные страницы, QR ---------- */
.public-content { max-width: 960px; }
.qr-img { width: 200px; height: 200px; image-rendering: pixelated; }
.mail-preview { width: 100%; height: 420px; border: 1px solid var(--bs-border-color); border-radius: .5rem; background: #fff; }

/* ---------- Модуль «Заявки» ---------- */
.tk-submit { max-width: 980px; }
.tk-tile { text-decoration: none; color: var(--bs-body-color); transition: transform .12s ease, box-shadow .12s ease; }
.tk-tile:hover { transform: translateY(-2px); box-shadow: var(--bs-box-shadow-sm); color: var(--bs-body-color); }
.tk-tile-icon { font-size: 2rem; line-height: 1; }
.tk-tile-sm .card-body { padding: .85rem 1rem; }
.tk-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; border-radius: 2rem; text-decoration: none;
    background: var(--bs-secondary-bg); color: var(--bs-body-color); font-size: .9rem; }
.tk-chip:hover { filter: brightness(.95); }
.tk-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.tk-done { max-width: 560px; }
.tk-kv th { width: 30%; font-weight: 500; color: var(--bs-secondary-color); font-size: .9rem; }
.tk-desc { white-space: normal; }
.tk-close-comment { background: var(--bs-success-bg-subtle); border-left: 3px solid var(--bs-success); padding: .4rem .75rem; border-radius: .25rem; }
.tk-row-overdue td { background: var(--bs-danger-bg-subtle) !important; }
.tk-table td { font-size: .9rem; }
.tk-num { max-width: 5.5rem; }
.tk-room-pattern { max-width: 12rem; }

.tk-timeline { display: flex; flex-direction: column; gap: .6rem; }
.tk-c { border-radius: .5rem; padding: .6rem .85rem; border-left: 4px solid transparent; }
.tk-c-public   { background: var(--bs-primary-bg-subtle); border-left-color: var(--bs-primary); }
.tk-c-internal { background: var(--bs-warning-bg-subtle); border-left-color: var(--bs-warning); }
.tk-c-info     { background: #6f42c11f; border-left-color: #6f42c1; }
.tk-c-req      { background: var(--bs-success-bg-subtle); border-left-color: var(--bs-success); }
.tk-c-system   { padding: .1rem .5rem; color: var(--bs-secondary-color); border-left: 0; }
.tk-badge-internal { background: var(--bs-warning); color: #000; }
.tk-badge-info_request { background: #6f42c1; color: #fff; }
.tk-badge-requester { background: var(--bs-success); color: #fff; }

.tk-qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tk-qr-card { border: 1px dashed var(--bs-border-color); border-radius: .5rem; padding: 1rem; text-align: center; background: #fff; color: #000; break-inside: avoid; }
.tk-qr-img { width: 180px; height: 180px; margin: .5rem auto; display: block; image-rendering: pixelated; }
.tk-qr-url { font-size: .65rem; word-break: break-all; color: #6c757d; margin-top: .4rem; }

@media print {
    .app-topbar, .app-sidebar, .tk-noprint, .nav-pills, .alert { display: none !important; }
    .app-content, .container-fluid { padding: 0 !important; }
    .tk-qr-grid { grid-template-columns: repeat(3, 1fr); }
    .tk-qr-card { border: 1px dashed #999; }
}

/* Контроль OWA: теги, отметки, учёт */
.ow-tag { font-weight: 500; }
.ow-tag-primary { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.ow-tag-secondary { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); }
.ow-tag-success { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.ow-tag-danger { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.ow-tag-warning { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.ow-tag-info { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.ow-tag-dark { background: var(--bs-dark); color: var(--bs-light); }
.ow-tag-purple { background: #e9ddff; color: #4b1d95; }
[data-bs-theme="dark"] .ow-tag-purple { background: #3b2566; color: #dccbff; }
[data-bs-theme="dark"] .ow-tag-dark { background: var(--bs-light); color: var(--bs-dark); }
.ow-mark { white-space: nowrap; }
.ow-mark .small { white-space: normal; color: var(--bs-secondary-color); }
.ow-mark-yes { color: var(--bs-success-text-emphasis); }
.ow-mark-no { color: var(--bs-danger-text-emphasis); }
.ow-mark-part { color: var(--bs-warning-text-emphasis); }
.ow-cell-clip { max-width: 18rem; }
.ow-stats-bar { width: 9rem; }
.ow-progress { height: .5rem; display: inline-flex; width: 5rem; vertical-align: middle; }
.ow-w-0 { width: 0%; }
.ow-w-5 { width: 5%; }
.ow-w-10 { width: 10%; }
.ow-w-15 { width: 15%; }
.ow-w-20 { width: 20%; }
.ow-w-25 { width: 25%; }
.ow-w-30 { width: 30%; }
.ow-w-35 { width: 35%; }
.ow-w-40 { width: 40%; }
.ow-w-45 { width: 45%; }
.ow-w-50 { width: 50%; }
.ow-w-55 { width: 55%; }
.ow-w-60 { width: 60%; }
.ow-w-65 { width: 65%; }
.ow-w-70 { width: 70%; }
.ow-w-75 { width: 75%; }
.ow-w-80 { width: 80%; }
.ow-w-85 { width: 85%; }
.ow-w-90 { width: 90%; }
.ow-w-95 { width: 95%; }
.ow-w-100 { width: 100%; }

/* Заявки: строка списка открывается кликом */
tr[data-href] { cursor: pointer; }
.tk-num-link { display: inline-block; padding: .15rem .5rem; border-radius: var(--bs-border-radius); font-weight: 600;
    background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); text-decoration: none; }
.tk-num-link:hover { background: var(--bs-primary); color: #fff; }
.tk-sel { width: 2rem; }

/* Заявки: дашборд */
.tk-progress { height: .5rem; display: inline-flex; width: 5rem; vertical-align: middle; }
.tk-chart { display: flex; align-items: flex-end; gap: .5rem; overflow-x: auto; padding-top: 1rem; }
.tk-chart-col { flex: 1 0 3rem; text-align: center; }
.tk-chart-bars { height: 10rem; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.tk-bar { width: 1.1rem; border-radius: 3px 3px 0 0; position: relative; min-height: 1px; }
.tk-bar span { position: absolute; top: -1.15rem; left: 50%; transform: translateX(-50%); font-size: .7rem; color: var(--bs-secondary-color); }
.tk-bar-in, .tk-legend-in { background: var(--bs-primary); }
.tk-bar-out, .tk-legend-out { background: var(--bs-success); }
.tk-legend { display: inline-block; width: .75rem; height: .75rem; border-radius: 2px; vertical-align: middle; }
.tk-chart-label { font-size: .75rem; line-height: 1.1; margin-top: .25rem; }
.tk-w-0 { width: 0%; }
.tk-w-5 { width: 5%; }
.tk-w-10 { width: 10%; }
.tk-w-15 { width: 15%; }
.tk-w-20 { width: 20%; }
.tk-w-25 { width: 25%; }
.tk-w-30 { width: 30%; }
.tk-w-35 { width: 35%; }
.tk-w-40 { width: 40%; }
.tk-w-45 { width: 45%; }
.tk-w-50 { width: 50%; }
.tk-w-55 { width: 55%; }
.tk-w-60 { width: 60%; }
.tk-w-65 { width: 65%; }
.tk-w-70 { width: 70%; }
.tk-w-75 { width: 75%; }
.tk-w-80 { width: 80%; }
.tk-w-85 { width: 85%; }
.tk-w-90 { width: 90%; }
.tk-w-95 { width: 95%; }
.tk-w-100 { width: 100%; }
.tk-h-0 { height: 0%; }
.tk-h-5 { height: 5%; }
.tk-h-10 { height: 10%; }
.tk-h-15 { height: 15%; }
.tk-h-20 { height: 20%; }
.tk-h-25 { height: 25%; }
.tk-h-30 { height: 30%; }
.tk-h-35 { height: 35%; }
.tk-h-40 { height: 40%; }
.tk-h-45 { height: 45%; }
.tk-h-50 { height: 50%; }
.tk-h-55 { height: 55%; }
.tk-h-60 { height: 60%; }
.tk-h-65 { height: 65%; }
.tk-h-70 { height: 70%; }
.tk-h-75 { height: 75%; }
.tk-h-80 { height: 80%; }
.tk-h-85 { height: 85%; }
.tk-h-90 { height: 90%; }
.tk-h-95 { height: 95%; }
.tk-h-100 { height: 100%; }
.tk-role-sel { flex: 1 1 10rem; min-width: 0; max-width: 100%; width: auto; }

/* Задачи */
.tsk-st { font-weight: 500; }
.tsk-st-new { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.tsk-st-in_progress { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.tsk-st-paused { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); }
.tsk-st-done { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.tsk-st-cancelled { background: var(--bs-dark-bg-subtle); color: var(--bs-dark-text-emphasis); }
.tsk-tag { font-weight: 500; }
.tsk-tag-primary { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.tsk-tag-secondary { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); }
.tsk-tag-success { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.tsk-tag-danger { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.tsk-tag-warning { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.tsk-tag-info { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.tsk-tag-dark { background: var(--bs-dark); color: var(--bs-light); }
.tsk-tag-purple { background: #e9ddff; color: #4b1d95; }
[data-bs-theme="dark"] .tsk-tag-purple { background: #3b2566; color: #dccbff; }
[data-bs-theme="dark"] .tsk-tag-dark { background: var(--bs-light); color: var(--bs-dark); }
.tsk-list .tsk-c-status { width: 8.5rem; }
.tsk-list .tsk-c-date { width: 9rem; }
.tsk-list .tsk-c-user { width: 11rem; }
.tsk-list .tsk-c-title { min-width: 16rem; }
.tsk-title-link { color: var(--bs-body-color); text-decoration: none; }
.tsk-title-link:hover { text-decoration: underline; }
.tsk-row-closed .tsk-title-link { color: var(--bs-secondary-color); text-decoration: line-through; }
.tsk-row-overdue > td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.tsk-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--bs-primary); vertical-align: middle; }
.tsk-text { overflow-wrap: anywhere; }
.tsk-progress { height: .4rem; width: 5rem; display: inline-flex; }
.tsk-tick { font-size: 1.15rem; line-height: 1; }
.tsk-item-done .me-auto > :first-child, .tsk-item-done .me-auto { color: var(--bs-secondary-color); }
.tsk-chat { max-height: 34rem; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; }
.tsk-msg { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius-lg); padding: .5rem .75rem; max-width: 92%; align-self: flex-start; }
.tsk-msg-mine { align-self: flex-end; background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border-subtle); }
.tsk-msg-done { border-color: var(--bs-success-border-subtle); background: var(--bs-success-bg-subtle); }
.tsk-msg-head { display: flex; gap: .5rem; font-size: .8rem; margin-bottom: .15rem; }
.tsk-msg-sys { font-size: .8rem; color: var(--bs-secondary-color); text-align: center; }
.tsk-new-divider { text-align: center; border-top: 1px solid var(--bs-primary); margin: .5rem 0 0; }
.tsk-new-divider span { position: relative; top: -.7rem; background: var(--bs-body-bg); color: var(--bs-primary); padding: 0 .5rem; font-size: .75rem; }
.tsk-thumb { max-height: 7rem; max-width: 10rem; border-radius: var(--bs-border-radius); border: 1px solid var(--bs-border-color); }
.tsk-w-0 { width: 0%; }
.tsk-w-5 { width: 5%; }
.tsk-w-10 { width: 10%; }
.tsk-w-15 { width: 15%; }
.tsk-w-20 { width: 20%; }
.tsk-w-25 { width: 25%; }
.tsk-w-30 { width: 30%; }
.tsk-w-35 { width: 35%; }
.tsk-w-40 { width: 40%; }
.tsk-w-45 { width: 45%; }
.tsk-w-50 { width: 50%; }
.tsk-w-55 { width: 55%; }
.tsk-w-60 { width: 60%; }
.tsk-w-65 { width: 65%; }
.tsk-w-70 { width: 70%; }
.tsk-w-75 { width: 75%; }
.tsk-w-80 { width: 80%; }
.tsk-w-85 { width: 85%; }
.tsk-w-90 { width: 90%; }
.tsk-w-95 { width: 95%; }
.tsk-w-100 { width: 100%; }

/* Закупки */
.prc-st { font-weight: 500; }
.prc-st-draft { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); border: 1px dashed var(--bs-secondary-border-subtle); }
.prc-st-new { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }
.prc-st-in_progress { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.prc-st-waiting { background: #ffe5d0; color: #8a3b00; }
[data-bs-theme="dark"] .prc-st-waiting { background: #4d2a10; color: #ffc89a; }
.prc-st-contracted { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.prc-st-delivered { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.prc-st-cancelled { background: var(--bs-dark-bg-subtle); color: var(--bs-dark-text-emphasis); }
.prc-list .prc-c-st { width: 11rem; }
.prc-list .prc-c-date { width: 8rem; }
.prc-list .prc-c-user { width: 10rem; }
.prc-list .prc-c-sup { width: 13rem; }
.prc-title-link { color: var(--bs-body-color); text-decoration: none; }
.prc-title-link:hover { text-decoration: underline; }
.prc-row-closed .prc-title-link { color: var(--bs-secondary-color); }
.prc-row-overdue > td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.prc-subject { max-width: 40rem; }
.prc-text { overflow-wrap: anywhere; }
.prc-items-edit .prc-c-qty { width: 6rem; }
.prc-items-edit .prc-c-unit { width: 6rem; }
.prc-items-edit .prc-c-price { width: 7rem; }
.prc-items-edit td { min-width: 4rem; }
.prc-log { background: var(--bs-tertiary-bg); }
.prc-internal { background: var(--bs-warning-bg-subtle); }
.prc-preview { width: 100%; height: 34rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: #e9ecef; }

/* Сертификаты */
.cert-badge { font-weight: 500; }
.cert-badge-valid { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.cert-badge-expiring { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.cert-badge-expired { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.cert-badge-future, .cert-badge-unknown { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.cert-badge-archived { background: var(--bs-secondary-bg-subtle); color: var(--bs-secondary-text-emphasis); }
.cert-date { white-space: nowrap; }
.cert-expired, .cert-expired-text { color: var(--bs-danger-text-emphasis); }
.cert-expired { font-weight: 600; }
.cert-expiring, .cert-expiring-text { color: var(--bs-warning-text-emphasis); }
.cert-expiring { font-weight: 600; }
.cert-valid-text, .cert-future-text, .cert-unknown-text { color: var(--bs-secondary-color); }
.cert-list .cert-c-st { width: 10rem; }
.cert-list .cert-c-date { width: 9.5rem; }
.cert-list .cert-c-user { width: 10rem; }
.cert-name { color: var(--bs-body-color); text-decoration: none; }
.cert-name:hover { text-decoration: underline; }
.cert-row-expired > td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.cert-row-expiring > td:first-child { box-shadow: inset 3px 0 0 var(--bs-warning); }
.cert-row-archived { opacity: .65; }
.cert-hist-old { background: var(--bs-tertiary-bg); }
.cert-text { overflow-wrap: anywhere; }

/* ---------- Формы сбора ---------- */
.fm-fill { max-width: 760px; }
.fm-narrow { max-width: 900px; }
.fm-search { max-width: 420px; }
.fm-num { max-width: 200px; }
.fm-short { max-width: 240px; }
.fm-kind { white-space: normal; }
.fm-head { border-top: 6px solid var(--bs-primary); }
.fm-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.fm-section { border-left: 4px solid var(--bs-primary); padding-left: .75rem; }
.fm-q-section { background: var(--bs-tertiary-bg); }
.fm-scale-btn { min-width: 2.6rem; }
.fm-cand { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.fm-cand-mark { color: var(--bs-border-color); }
.btn-check:checked + .fm-cand { border-color: var(--bs-success); box-shadow: 0 0 0 .2rem rgba(var(--bs-success-rgb), .25); }
.btn-check:checked + .fm-cand .fm-cand-mark { color: var(--bs-success); }
.btn-check:focus-visible + .fm-cand { box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .35); }
.fm-cand-photo { width: 96px; height: 120px; object-fit: cover; border-radius: .375rem; flex-shrink: 0; }
.fm-cand-photo-sm { width: 56px; height: 70px; object-fit: cover; border-radius: .25rem; flex-shrink: 0; }
.fm-cand-photo-xs { width: 28px; height: 34px; object-fit: cover; border-radius: .2rem; }
.fm-cand-nophoto { display: inline-flex; align-items: center; justify-content: center; background: var(--bs-secondary-bg); color: var(--bs-secondary-color); font-size: 2rem; }
.fm-cand-photo-sm.fm-cand-nophoto { font-size: 1.4rem; }
.fm-progress { height: .6rem; }
.fm-qr svg { width: 220px; height: 220px; max-width: 70vw; }
.fm-ticket { border: 2px dashed var(--bs-primary); }
.fm-table th.fm-col { min-width: 140px; }
.fm-table-wrap { max-height: 75vh; }
.fm-answers li + li { margin-top: .25rem; }
.fm-scan video { max-height: 50vh; object-fit: cover; }
@media print { .fm-ticket { border-color: #000; } nav.navbar { display: none !important; } }
.fm-w-0 { width: 0%; }
.fm-w-5 { width: 5%; }
.fm-w-10 { width: 10%; }
.fm-w-15 { width: 15%; }
.fm-w-20 { width: 20%; }
.fm-w-25 { width: 25%; }
.fm-w-30 { width: 30%; }
.fm-w-35 { width: 35%; }
.fm-w-40 { width: 40%; }
.fm-w-45 { width: 45%; }
.fm-w-50 { width: 50%; }
.fm-w-55 { width: 55%; }
.fm-w-60 { width: 60%; }
.fm-w-65 { width: 65%; }
.fm-w-70 { width: 70%; }
.fm-w-75 { width: 75%; }
.fm-w-80 { width: 80%; }
.fm-w-85 { width: 85%; }
.fm-w-90 { width: 90%; }
.fm-w-95 { width: 95%; }
.fm-w-100 { width: 100%; }

/* ---------- Запись на приём ---------- */
.ap-wrap { max-width: 760px; }
.ap-photo { width: 72px; height: 90px; object-fit: cover; border-radius: .5rem; flex-shrink: 0; }
.ap-nophoto { display: inline-flex; align-items: center; justify-content: center; background: var(--bs-secondary-bg); color: var(--bs-secondary-color); font-size: 2rem; }
.ap-card { color: var(--bs-body-color); transition: box-shadow .12s ease, border-color .12s ease; }
.ap-card:hover, .ap-card:focus-visible { border-color: var(--bs-primary); box-shadow: var(--bs-box-shadow-sm); color: var(--bs-body-color); }
.ap-steps .ap-step { color: var(--bs-secondary-color); display: flex; align-items: center; gap: .3rem; }
.ap-steps .ap-step + .ap-step::before { content: "›"; margin-right: .3rem; color: var(--bs-secondary-color); }
.ap-step-num { display: inline-flex; width: 1.4rem; height: 1.4rem; border-radius: 50%; align-items: center; justify-content: center; background: var(--bs-secondary-bg); font-size: .75rem; }
.ap-step.current { color: var(--bs-body-color); font-weight: 600; }
.ap-step.current .ap-step-num { background: var(--bs-primary); color: #fff; }
.ap-step.done .ap-step-num { background: var(--bs-success); color: #fff; }
.ap-cal { table-layout: fixed; text-align: center; border-collapse: separate; border-spacing: 3px; }
.ap-cal td { padding: 0; height: 3rem; }
.ap-day { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; border-radius: .5rem; color: var(--bs-secondary-color); }
.ap-day.ap-today { outline: 1px dashed var(--bs-border-color); }
.ap-day-free { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); font-weight: 600; text-decoration: none; }
.ap-day-free:hover, .ap-day-free:focus-visible { background: var(--bs-primary); color: #fff; }
.ap-day-free.active { background: var(--bs-primary); color: #fff; }
.ap-day-n { font-size: .65rem; font-weight: 400; opacity: .85; }
.ap-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr)); gap: .5rem; }
.ap-time { min-width: 3.2rem; }
.ap-date-box { width: 3.5rem; line-height: 1.1; }
.ap-wd { min-width: 2.6rem; }

/* ---------- Приложение (PWA) ---------- */
.pwa-banner {
    position: fixed; left: .75rem; right: .75rem; bottom: .75rem; z-index: 1080;
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
    padding: .75rem 1rem; border-radius: 1rem; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
    max-width: 560px; margin: 0 auto;
}
.pwa-banner-icon { width: 44px; height: 44px; border-radius: .7rem; flex-shrink: 0; }
.pwa-banner-text { flex: 1 1 200px; }
.pwa-banner-actions { display: flex; gap: .25rem; margin-left: auto; }
.pwa-share { display: inline-block; padding: 0 .3rem; border: 1px solid var(--bs-border-color); border-radius: .3rem; }
@media (display-mode: standalone) { .app-topbar { padding-top: env(safe-area-inset-top); } }

/* ---------- Генератор паролей ---------- */
.pg-min { width: 4.2rem; }
.pg-pw { letter-spacing: .04em; }
.pg-mask { color: var(--bs-secondary-color); letter-spacing: .1em; }
.pg-label { min-width: 9rem; }
[data-pg-value] { word-break: break-all; }
[data-pg-value] { display: inline-block; min-width: 11rem; }
.pg-mask { white-space: nowrap; }

/* ---------- Код для входа в приложение ---------- */
.pin-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pin-dots { display: flex; justify-content: center; gap: .9rem; margin: .5rem 0 1.25rem; }
.pin-dot { width: .95rem; height: .95rem; border-radius: 50%; border: 2px solid var(--bs-primary); transition: background .1s; }
.pin-dot.filled { background: var(--bs-primary); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 4.5rem); gap: .9rem 1.4rem; justify-content: center; }
.pin-key { width: 4.5rem; height: 4.5rem; border-radius: 50%; border: 0; background: var(--bs-secondary-bg); color: var(--bs-body-color); font-size: 1.6rem; font-weight: 500; }
.pin-key:active, .pin-key:focus-visible { background: var(--bs-primary); color: #fff; }
.pin-key-del { background: transparent; font-size: 1.3rem; }
.pin-shake { animation: pin-shake .4s; }
@keyframes pin-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- Установленное приложение: без увеличения страницы (два пальца, двойное касание) ---------- */
body.in-app { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* ---------- Установленное приложение: нижняя панель ---------- */
.app-bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: flex; justify-content: space-around; align-items: stretch;
    background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color);
    padding-bottom: env(safe-area-inset-bottom);
}
.app-bottom-nav a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
    padding: .45rem .1rem .35rem; color: var(--bs-secondary-color); text-decoration: none; font-size: .7rem; line-height: 1.1;
}
.app-bottom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bottom-nav .bi { font-size: 1.35rem; }
.app-bottom-nav .active { color: var(--bs-primary); font-weight: 600; }
body.in-app .app-content { padding-bottom: calc(4.2rem + env(safe-area-inset-bottom)); }
body.in-app .pwa-banner { bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
@media (min-width: 992px) { .app-bottom-nav { justify-content: center; } .app-bottom-nav a { flex: 0 0 8rem; } }

/* ---------- Телефон: таблицы карточками ---------- */
@media (max-width: 767.98px) {
    table.table-stack thead { display: none; }
    table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td { display: block; width: 100%; }
    table.table-stack tr { border: 1px solid var(--bs-border-color); border-radius: .6rem; margin-bottom: .6rem; padding: .35rem .6rem; background: var(--bs-body-bg); }
    table.table-stack > :not(caption) > * > * { border: 0; padding: .2rem 0; box-shadow: none; }
    table.table-stack td[data-label]:not([data-label=""])::before {
        content: attr(data-label); display: block; font-size: .72rem; color: var(--bs-secondary-color); text-transform: none; font-weight: 400;
    }
    table.table-stack td:first-child { font-weight: 600; }
    table.table-stack td:empty { display: none; }
    table.table-stack tr.stack-full { border-style: dashed; text-align: center; }
    table.table-stack tr.stack-full td { font-weight: 400; }
    .table-responsive:has(> table.table-stack) { overflow: visible; }
    table.table-stack td.text-end { text-align: left !important; }
    .card > .table-responsive > table.table-stack { padding: .6rem .6rem 0; }
    table.prc-items-edit.table-stack td { min-width: 0; }
    table.prc-items-edit.table-stack td:last-child { text-align: right; }
}

/* ---------- Телефон: удобные касания, без увеличения при вводе на iPhone ---------- */
@media (pointer: coarse) {
    .form-control, .form-select, .form-control-sm, .form-select-sm, .input-group-sm > .form-control, .input-group-sm > .form-select { font-size: 16px; }
    .btn-sm, .btn-group-sm > .btn { min-height: 2.25rem; padding-top: .35rem; padding-bottom: .35rem; }
    .form-check-input { width: 1.2em; height: 1.2em; }
    .form-switch .form-check-input { width: 2.2em; }
    .dropdown-item { padding-top: .55rem; padding-bottom: .55rem; }
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
    .nav-tabs .nav-link { white-space: nowrap; }
}

/* поля «по содержимому» (выбор файла и т. п.) не шире экрана телефона */
.form-control.w-auto, .form-select.w-auto { max-width: 100%; }
.error-box { max-width: 36rem; }
.sidebar-help { display: block; margin-top: auto; padding: .75rem .9rem; color: var(--bs-secondary-color); text-decoration: none; }
.sidebar-help:hover { color: var(--bs-primary); }

/* переносы строк, введённые в редакторе справки */
.text-prewrap { white-space: pre-line; }
.help-materials li { margin-bottom: .35rem; }

/* ---------- Быстрые ссылки: редактор ---------- */
.links-admin[class*="lp-"] { background: none !important; color: inherit !important; }
.links-tree { list-style: none; padding-left: 0; margin: 0; }
.links-tree .links-tree { padding-left: 1.6rem; margin-top: .5rem; border-left: 2px dashed var(--bs-border-color); }
.links-row { padding: .55rem .6rem; border: 1px solid var(--bs-border-color); border-radius: .6rem; margin-bottom: .5rem; background: var(--bs-body-bg); }
.links-row:target { box-shadow: 0 0 0 3px var(--bs-primary-border-subtle); }
.links-swatch { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border-radius: .55rem; font-size: 1.2rem; flex-shrink: 0; }
.links-swatch img { max-width: 1.8rem; max-height: 1.8rem; object-fit: contain; }
.links-empty, .links-add { padding: .25rem .4rem; }
.links-preview { max-height: 56px; max-width: 160px; border-radius: .4rem; border: 1px solid var(--bs-border-color); }
.links-preview-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 130px;
                      border-radius: 1rem; text-align: center; padding: 1rem; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.links-pv-icon { font-size: 2.3rem; line-height: 1; }
.links-pv-name { font-weight: 600; }
.links-icon-pick { display: flex; flex-wrap: wrap; gap: .25rem; }
.links-icon-pick .btn { width: 2.2rem; height: 2.2rem; padding: 0; }
.links-host { max-width: 55%; }
.min-w-0 { min-width: 0; }
