/* ==========================================================================
   Kobalt Control Retail — client (guard-facing) UI
   Mobile-first. Shares design tokens/typography with the admin panel.
   ========================================================================== */

:root {
    --navy: #0A1628;
    --ink: #0A1628;
    --muted: #5A7090;
    --muted2: #94A8BE;
    --teal: #0E9E8A;
    --teal-light: #49D0C1;
    --teal-soft: #E5F7F4;
    --cobalt: #1755C8;
    --cobalt-soft: #E9F0FD;
    --red: #C0392B;
    --red-soft: #FDEBE9;
    --amber: #D97706;
    --amber-soft: #FEF3E2;
    --green: #16A34A;
    --green-soft: #EAFBF1;
    --bg: #F4F7FA;
    --surface: #FFFFFF;
    --surface-2: #F9FAFB;
    --border: #E4ECF4;
    --shadow: 0 1px 2px rgba(10, 22, 40, .04), 0 8px 24px rgba(10, 22, 40, .06);
    --navy-glass: rgba(10, 22, 40, .82);
    --surface-glass: rgba(255, 255, 255, .78);
}

:root[data-theme="dark"] {
    --ink: #EAF1F8;
    --muted: #93A7C4;
    --muted2: #6C81A0;
    --bg: #0A1628;
    --surface: #101F3A;
    --surface-2: #16294A;
    --border: rgba(255, 255, 255, .08);
    --cobalt: #4C86EE;
    --cobalt-soft: rgba(76, 134, 238, .16);
    --teal-soft: rgba(73, 208, 193, .14);
    --red: #E2604F;
    --red-soft: rgba(226, 96, 79, .14);
    --amber: #F0A83D;
    --amber-soft: rgba(240, 168, 61, .14);
    --green: #34D399;
    --green-soft: rgba(52, 211, 153, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --navy-glass: rgba(6, 13, 26, .82);
    --surface-glass: rgba(16, 31, 58, .74);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #EAF1F8;
        --muted: #93A7C4;
        --muted2: #6C81A0;
        --bg: #0A1628;
        --surface: #101F3A;
        --surface-2: #16294A;
        --border: rgba(255, 255, 255, .08);
        --cobalt: #4C86EE;
        --cobalt-soft: rgba(76, 134, 238, .16);
        --teal-soft: rgba(73, 208, 193, .14);
        --red: #E2604F;
        --red-soft: rgba(226, 96, 79, .14);
        --amber: #F0A83D;
        --amber-soft: rgba(240, 168, 61, .14);
        --green: #34D399;
        --green-soft: rgba(52, 211, 153, .14);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
        --navy-glass: rgba(6, 13, 26, .82);
        --surface-glass: rgba(16, 31, 58, .74);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    /* Долгий тап по любому тексту на Android иначе выделяет слово и
       предлагает "Найти в Google" — это не текстовый документ, а набор
       контролов, выделять тут почти нечего. Поля ввода — исключение ниже,
       иначе в них сломается обычное редактирование/курсор/выделение. */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

a { color: inherit; }

button, input, textarea {
    font-family: inherit;
}

:focus-visible {
    outline: 2px solid var(--cobalt);
    outline-offset: 2px;
}

.container {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 0 max(16px, env(safe-area-inset-bottom, 0px));
}

/* ── Sticky stack: только часы + прогресс/отметки, не магазин/охранник ──── */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 40;
}

/* ── Обычная (не закреплённая) шапка: магазин / охранник / язык / документы */
.topbar {
    background: var(--navy);
    color: #fff;
    padding: max(14px, env(safe-area-inset-top, 0px)) 16px 16px;
}

.topbar-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-brand svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.topbar-store {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.topbar-guard {
    font-size: 12.5px;
    color: rgba(255, 255, 255, .6);
    margin-top: 2px;
}

.topbar-docs {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-doc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .85);
    font-size: 16px;
    cursor: pointer;
    transition: background .15s;
}

.topbar-doc-btn:hover, .topbar-doc-btn:active {
    background: rgba(255, 255, 255, .16);
}

.topbar-instructions-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1755C8, #2E6FE0);
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(23, 85, 200, .45);
    transition: filter .15s;
}

.topbar-instructions-btn i { font-size: 16px; }

.topbar-instructions-btn:hover, .topbar-instructions-btn:active {
    filter: brightness(1.08);
}

.topbar-switch-post-btn {
    height: 32px;
    padding: 0 14px;
    gap: 5px;
    justify-content: center;
    border-radius: 9px;
    font-size: 12.5px;
    background: linear-gradient(135deg, #C2650A, #F0A83D);
    box-shadow: 0 2px 8px rgba(194, 101, 10, .4);
}

.topbar-switch-post-btn i {
    font-size: 14px;
}

.topbar-switch-post-btn.loading {
    pointer-events: none;
    filter: brightness(.95);
}

/* ── Instructions list (instructions.html) ──────────────────────────────── */
.doc-card-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    width: 100%;
    color: inherit;
    font: inherit;
}

.doc-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--cobalt);
    font-size: 20px;
    flex-shrink: 0;
}

.doc-card-icon--cobalt { background: var(--cobalt-soft); color: var(--cobalt); }
.doc-card-icon--teal { background: var(--teal-soft); color: var(--teal); }
.doc-card-icon--amber { background: var(--amber-soft); color: var(--amber); }

.doc-card-body { flex: 1; min-width: 0; }

.doc-card-title {
    font-size: 15px;
    font-weight: 650;
    color: var(--ink);
}

.doc-card-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.doc-card-row .ti-chevron-right {
    margin-left: auto;
    color: var(--muted);
    flex-shrink: 0;
}

.doc-section-label {
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted2);
    margin: 4px 0 10px;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    flex-shrink: 0;
    margin-top: 3px;
}

.lang-toggle a {
    color: rgba(255, 255, 255, .4);
    text-decoration: none;
    padding: 4px 3px;
}

.lang-toggle a.active {
    color: var(--teal-light);
}

.lang-toggle span {
    color: rgba(255, 255, 255, .2);
}

.duty-timer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    background: var(--navy-glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    padding: max(14px, env(safe-area-inset-top, 0px)) 16px 10px;
}

.duty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Обход — отдельная строка внутри той же стеклянной шапки, появляется на
   время активного обхода (Jinja-условие на первую отрисовку, JS показывает/
   прячет при офлайн-старте/завершении — см. startLocalPatrolRound и
   showPatrolRoundFinishedQueued в шаблоне). */
.duty-patrol {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(76, 134, 238, .18);
    color: #86AFF5;
    font-size: 12.5px;
    font-weight: 650;
    cursor: pointer;
    transition: background 120ms ease-out;
}

.duty-patrol:active {
    background: rgba(76, 134, 238, .3);
}

.duty-patrol.expired:active {
    background: rgba(226, 96, 79, .32);
}

.duty-patrol i {
    font-size: 14px;
    flex-shrink: 0;
}

.duty-patrol i.ti-chevron-right {
    font-size: 15px;
    opacity: .6;
}

.duty-patrol-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duty-patrol-timer {
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.duty-patrol.expired {
    background: rgba(226, 96, 79, .2);
    color: #F0968A;
}

/* Светлая кромка сверху — свет, "ловящийся" материалом, как у стекла */
.duty-timer::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
}

.duty-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.duty-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 650;
}

.duty-hours {
    font-size: 12px;
    color: rgba(255, 255, 255, .55);
    font-variant-numeric: tabular-nums;
}

.duty-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}

.duty-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--teal-light);
    box-shadow: 0 0 0 3px rgba(73, 208, 193, .22);
    flex-shrink: 0;
    align-self: center;
    animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
    .duty-dot { animation: none; }
}

.duty-label {
    font-size: 11px;
    color: rgba(255, 255, 255, .55);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

.duty-value {
    font-variant-numeric: tabular-nums;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.dev-banner {
    background: var(--red);
    color: #fff;
    text-align: center;
    padding: 4px 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    position: sticky;
    top: 0;
    z-index: 9999;
}

/* Офлайн-очередь — сам себя вставляет в начало <body>, см.
   static/js/offline-queue.js. */
.offline-queue-banner {
    position: sticky;
    top: 0;
    z-index: 9998;
    cursor: pointer;
}

.offline-queue-row {
    background: var(--amber-soft);
    color: var(--amber);
    text-align: center;
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 650;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.offline-queue-row.failed {
    background: var(--red-soft);
    color: var(--red);
}

.offline-queue-row + .offline-queue-row {
    border-top: 1px solid rgba(0, 0, 0, .06);
}

.offline-queue-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: offlineQueueSpin .7s linear infinite;
}

@keyframes offlineQueueSpin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .offline-queue-spinner { animation: none; }
}

/* Шторка "Нет соединения" (клик/Enter по полоске выше) — выезжает СВЕРХУ,
   визуально продолжая саму полоску (тот же янтарный), а не всплывает снизу
   как остальные .sheet-overlay модалки на странице — те про действия
   охранника (отметить/подтвердить), эта скорее про статус системы. */
.offline-queue-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, .45);
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
}

.offline-queue-modal-overlay.open { display: flex; }

.offline-queue-panel {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border-radius: 0 0 18px 18px;
    box-shadow: 0 12px 30px rgba(10, 22, 40, .22);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(-100%);
    transition: transform .25s ease;
}

.offline-queue-modal-overlay.open-anim .offline-queue-panel {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .offline-queue-panel { transition: none; }
}

.offline-queue-panel-header {
    background: var(--amber-soft);
    color: var(--amber);
    padding: 16px 16px 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: inherit;
}

.offline-queue-panel-header.failed {
    background: var(--red-soft);
    color: var(--red);
}

.offline-queue-panel-header h3 {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
}

.offline-queue-panel-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 24px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.offline-queue-panel-body {
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
}

.offline-queue-panel-status {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--muted);
}

.offline-queue-event-list {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.offline-queue-event-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
}

.offline-queue-event-row + .offline-queue-event-row {
    border-top: 1px solid var(--border);
}

.offline-queue-event-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.offline-queue-event-kind {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--ink);
}

.offline-queue-event-time {
    font-size: 11.5px;
    color: var(--muted);
}

.offline-queue-event-status {
    font-size: 11px;
    font-weight: 650;
    flex-shrink: 0;
    padding: 3px 9px;
    border-radius: 20px;
}

.offline-queue-event-row.pending .offline-queue-event-status {
    background: var(--amber-soft);
    color: var(--amber);
}

.offline-queue-event-row.failed .offline-queue-event-status {
    background: var(--red-soft);
    color: var(--red);
}

.offline-queue-event-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--red-soft);
    color: var(--red);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.offline-queue-event-empty {
    padding: 20px 12px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.offline-queue-retry-btn {
    width: 100%;
    min-height: 48px;
    border: none;
    border-radius: 10px;
    background: var(--cobalt);
    color: #fff;
    font-size: 15px;
    font-weight: 650;
    cursor: pointer;
}

.offline-queue-retry-btn:disabled {
    opacity: .6;
    cursor: default;
}

.offline-queue-retry-btn:disabled {
    opacity: .6;
}

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress-bar-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    position: relative;
    background: var(--surface-glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-bottom: 1px solid var(--border);
}

.progress-bar-compact::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent);
}

/* Если часов нет (смена завершена) — прогресс-бар первый в sticky-стеке,
   сам берёт на себя отступ под чёлку/статус-бар. */
.sticky-top > .progress-bar-compact:first-child {
    padding-top: max(16px, env(safe-area-inset-top, 0px));
}

/* Полоса с отметками — кликабельна, прокручивает к их детальной карточке */
.progress-bar-clickable {
    cursor: pointer;
}

.progress-bar-clickable i.ti-chevron-right {
    font-size: 15px;
    color: var(--muted2);
    flex-shrink: 0;
}

.progress-step-compact {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    position: relative;
    font-size: 0;
    color: transparent;
}

.progress-step-compact.active { background: var(--cobalt); }
.progress-step-compact.completed { background: var(--teal); }

.progress-step-compact .step-number-compact { display: none; }

.progress-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    padding-left: 4px;
}

/* ── Отметки присутствия, встроенные в закреплённую полосу прогресса ────── */
.progress-cps {
    display: flex;
    gap: 8px;
    flex: 1;
    padding: 4px;
    border-radius: 10px;
    /* Заливка позади отметок слева (пройдено) направо (осталось) — доля
       --shift-progress считается в JS (updateShiftProgress) по графику смены */
    background: linear-gradient(to right,
        var(--teal-soft) 0%, var(--teal-soft) var(--shift-progress, 0%),
        var(--surface-2) var(--shift-progress, 0%), var(--surface-2) 100%);
}

.progress-cp {
    flex: 1;
    text-align: center;
    padding: 5px 2px;
    border-radius: 7px;
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.progress-cp.done { background: var(--green-soft); color: var(--green); }
.progress-cp.missed { background: var(--red-soft); color: var(--red); }

.progress-cp.active {
    background: var(--cobalt);
    color: #fff;
    animation: progressCpPulse 1.4s ease-in-out infinite;
}

@keyframes progressCpPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(23, 85, 200, .55); }
    50%      { box-shadow: 0 0 0 6px rgba(23, 85, 200, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .progress-cp.active { animation: none; }
}

/* ── Content wrapper ────────────────────────────────────────────────────── */
.content {
    padding: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Cards: во всю ширину экрана, без рамок — только контраст фона ──────── */
.card, .step-card, .info-panel-new {
    background: var(--surface);
    padding: 16px;
}

.step-card h2, .card h2 {
    font-size: 16px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 4px;
}

.step-card > p, .card .sub {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 16px;
}

/* ── Store info card (guards.html / shift.html) ────────────────────────── */
.store-title {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.store-title h1 {
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 4px;
    font-weight: 700;
}

.guard-subtitle {
    font-size: 13.5px;
    color: var(--muted);
}

.info-contacts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.contact-item {
    padding: 10px;
    background: var(--surface-2);
    border-radius: 8px;
}

.contact-item.emergency-contact {
    background: var(--red-soft);
    text-align: center;
}

.contact-item.emergency-contact .contact-value {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.contact-label {
    font-size: 10.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    margin-bottom: 4px;
}

.contact-value {
    font-size: 14px;
    color: var(--ink);
    font-weight: 600;
}

.contact-value a { color: var(--cobalt); text-decoration: none; }
.contact-value a:hover { text-decoration: underline; }

.emergency-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(160deg, #ED5647, var(--red));
    box-shadow: 0 8px 20px rgba(192, 57, 43, .38), inset 0 1px 0 rgba(255, 255, 255, .25);
    color: #fff !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    transition: transform 120ms cubic-bezier(.2, .8, .3, 1.3);
}

.emergency-link:active {
    transform: scale(.92);
}

@media (max-width: 420px) {
    .info-contacts { grid-template-columns: 1fr 1fr; }
}

/* ── Document buttons ───────────────────────────────────────────────────── */
.btn-doc {
    padding: 8px 12px;
    background: var(--surface-2);
    color: var(--cobalt);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
    min-height: 40px;
}

.btn-doc:active { transform: scale(.98); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 22px;
    min-height: 48px;
    border-radius: 10px;
    border: none;
    font-size: 15.5px;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    width: 100%;
}

.btn-primary { background: var(--cobalt); color: #fff; }
.btn-primary:disabled { background: var(--border); color: var(--muted2); cursor: not-allowed; }

.btn-secondary { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.btn-danger { background: var(--red); color: #fff; }

/* ── Отклик на нажатие, а не на отпускание ───────────────────────────────
   :active срабатывает по touchstart/mousedown, а не по touchend/click —
   охранник видит реакцию сразу, не дожидаясь снятия пальца с экрана. */
.btn-primary, .btn-secondary, .btn-danger,
.btn-choice, .checkpoint-btn, .patrol-mark-btn,
.patrol-start-btn, .patrol-end-link,
.sheet-actions button,
.action-btn, .emergency-button, .detention-button,
.btn-toggle, .btn-problem-submit, .btn-problem-cancel {
    transition: transform 100ms ease-out;
}

.btn-primary:active, .btn-secondary:active, .btn-danger:active,
.btn-choice:active:not(:disabled), .checkpoint-btn:active:not(:disabled), .patrol-mark-btn:active,
.patrol-start-btn:active, .patrol-end-link:active,
.sheet-actions button:active:not(:disabled),
.action-btn:active, .emergency-button:active, .detention-button:active,
.btn-toggle:active, .btn-problem-submit:active, .btn-problem-cancel:active {
    transform: scale(.97);
}

@media (prefers-reduced-motion: reduce) {
    .btn-primary, .btn-secondary, .btn-danger,
    .btn-choice, .checkpoint-btn, .patrol-mark-btn,
    .patrol-start-btn, .patrol-end-link,
    .sheet-actions button,
    .action-btn, .emergency-button, .detention-button,
    .btn-toggle, .btn-problem-submit, .btn-problem-cancel {
        transition: none;
    }
}

/* Акцентная CTA-кнопка (напр. «Начать дежурство») */
.btn-cta {
    min-height: 56px;
    font-size: 16.5px;
    gap: 8px;
    box-shadow: 0 6px 18px rgba(23, 85, 200, .35);
}

.btn-cta:disabled {
    box-shadow: none;
}

.btn-cta i {
    font-size: 19px;
}

/* ── Селфи перед началом смены (шаг «Фото») ─────────────────────────────── */
.photo-capture-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 200px;
    border: 2px dashed var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
}

.photo-capture-box i {
    font-size: 34px;
}

.photo-capture-box span {
    font-size: 14px;
    font-weight: 650;
}

.photo-capture-box.has-photo {
    border-style: solid;
    border-color: var(--teal);
}

.photo-capture-box img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-retake-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(10, 22, 40, .6);
    color: #fff;
    font-size: 11.5px;
    font-weight: 650;
    padding: 5px 10px;
    border-radius: 20px;
}

.btn-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 2px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    vertical-align: -3px;
    animation: btn-spin .7s linear infinite;
}

/* Кнопки со светлым/нейтральным фоном — белый спиннер на них не виден */
.btn-secondary .btn-spinner,
.btn-choice .btn-spinner {
    border-color: rgba(90, 112, 144, .3);
    border-top-color: var(--muted);
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-spinner { animation: none; }
}

/* Кнопки действий, отключённые на время отправки формы (защита от повторных нажатий) */
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-choice:disabled,
.btn-start:disabled,
.sheet-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.photo-upload-error {
    margin-top: 10px;
    background: var(--red-soft);
    color: var(--red);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    text-align: center;
}

/* ── Guard list (guards.html) ───────────────────────────────────────────── */
.guard-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.guard-info { flex: 1; min-width: 0; }

.guard-name-row {
    font-size: 16px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 4px;
}

.guard-phone-row {
    font-size: 13.5px;
    color: var(--muted);
}

.btn-start {
    padding: 12px 18px;
    font-size: 14px;
    white-space: nowrap;
    min-width: 128px;
    width: auto;
}

@media (max-width: 420px) {
    .guard-card-row { flex-direction: column; align-items: stretch; }
    .btn-start { width: 100%; }
}

/* ── Post selection (select_post.html) ──────────────────────────────────── */
.post-tile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 12px;
}

.post-tile {
    position: relative;
    width: 100%;
    min-height: 148px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    padding: 28px 18px;
    text-align: center;
    transition: border-color .15s, background .15s, transform .1s;
}

.post-tile:hover {
    border-color: var(--cobalt);
    background: var(--cobalt-soft);
}

.post-tile:active {
    transform: scale(.97);
}

.post-tile.current {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.post-tile.loading {
    pointer-events: none;
    opacity: .7;
}

.post-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--cobalt-soft);
    color: var(--cobalt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.post-tile.current .post-tile-icon {
    background: var(--teal-soft);
    color: var(--teal);
}

.post-tile .btn-spinner {
    border-color: rgba(90, 112, 144, .3);
    border-top-color: var(--cobalt);
    width: 22px;
    height: 22px;
    margin-right: 0;
}

.post-tile-shift-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--green-soft);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.post-tile-current {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--teal);
}

.post-tile-number {
    font-size: 17px;
    font-weight: 650;
    color: var(--ink);
}

.post-tile-desc {
    font-size: 13px;
    color: var(--muted);
}

.post-tile-status {
    font-size: 11px;
    color: var(--muted2);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-tile-status.open {
    color: var(--green);
    font-weight: 600;
}

@media (max-width: 380px) {
    .post-tile-grid { grid-template-columns: 1fr; }
}

/* Смена поста отправлена в офлайн-очередь, ждёт синхронизации — см.
   static/js/offline-queue.js. Тот же amber-язык, что у меток/чекпоинтов. */
.post-tile.queued {
    pointer-events: none;
    border-color: rgba(217, 119, 6, .35) !important;
    background: var(--amber-soft) !important;
}

.post-tile-grid.has-queued .post-tile:not(.queued) {
    pointer-events: none;
    opacity: .5;
}

/* ── Equipment check (form, step 1) ─────────────────────────────────────── */
.check-item {
    margin-bottom: 18px;
    padding: 16px;
    background: var(--surface-2);
    border-radius: 10px;
}

.check-item:last-of-type { margin-bottom: 0; }

.check-item > div:first-child {
    font-size: 14.5px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 12px;
}

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-choice {
    padding: 14px 8px;
    min-height: 48px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 650;
    cursor: pointer;
    background: var(--surface);
    color: var(--muted);
}

.btn-works.active {
    background: var(--green-soft);
    color: var(--green);
    border-color: var(--green);
}

.btn-not-works.active {
    background: var(--red-soft);
    color: var(--red);
    border-color: var(--red);
}

.btn-works-locked {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Ситуация на объекте (после отметки присутствия/обхода) — сразу видно, где
   какой выбор, а не только после нажатия, как у проверок оборудования */
#situationChoiceButtons .btn-works,
#patrolSituationChoiceButtons .btn-works {
    background: var(--green-soft);
    color: var(--green);
    border-color: var(--green);
}

#situationChoiceButtons .btn-not-works,
#patrolSituationChoiceButtons .btn-not-works {
    background: var(--red-soft);
    color: var(--red);
    border-color: var(--red);
}

.problem-field {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.problem-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--muted);
    font-size: 13px;
}

.problem-field textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14.5px;
    background: var(--surface);
    color: var(--ink);
    resize: vertical;
}

.problem-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.btn-problem-submit, .btn-problem-cancel {
    flex: 1;
    padding: 12px 14px;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
}

.btn-problem-submit { background: var(--red); color: #fff; }
.btn-problem-cancel { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

/* ── Фото к проверке (необязательное вложение при «Не работает») ────────── */
.check-photo-attach {
    margin-top: 12px;
}

.check-photo-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 650;
    cursor: pointer;
}

.check-photo-trigger i {
    font-size: 16px;
}

.check-photo-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.check-photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.check-photo-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.check-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.check-photo-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(10, 22, 40, .65);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Checkpoints ────────────────────────────────────────────────────────── */
.checkpoints-section {
    /* Место под sticky-шапку (часы + полоса отметок), чтобы клик по полосе
       не прокручивал блок ровно под неё. */
    scroll-margin-top: 100px;
}

.checkpoints-section h3 {
    font-size: 15px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 4px;
}

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

.checkpoint-item {
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    border: 1.5px solid var(--border);
    background: var(--surface-2);
}

.checkpoint-time {
    font-size: 16px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    margin-bottom: 4px;
}

.checkpoint-status {
    font-size: 12px;
    font-weight: 600;
}

.checkpoint-date {
    font-size: 11.5px;
    color: var(--muted2);
    margin-top: 2px;
}

.checkpoint-btn {
    margin-top: 10px;
    width: 100%;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 650;
    background: var(--cobalt);
    color: #fff;
    cursor: pointer;
}

.checkpoint-inactive, .checkpoints-grid .checkpoint-item.checkpoint-inactive {
    opacity: .4;
}

.checkpoint-btn-inactive, .checkpoints-grid .checkpoint-btn.checkpoint-btn-inactive {
    background: var(--border) !important;
    color: var(--muted2) !important;
    cursor: not-allowed !important;
}

@keyframes checkpointPulseUrgent {
    0%, 100% { box-shadow: 0 0 0 0 rgba(23, 85, 200, .35); }
    50% { box-shadow: 0 0 0 6px rgba(23, 85, 200, 0); }
}

.checkpoint-blink-urgent {
    animation: checkpointPulseUrgent 1.6s ease-in-out infinite;
    background: var(--cobalt) !important;
    border-color: var(--cobalt) !important;
}

.checkpoint-blink-urgent .checkpoint-time,
.checkpoint-blink-urgent .checkpoint-status {
    color: #fff !important;
}

@media (prefers-reduced-motion: reduce) {
    .checkpoint-blink-urgent { animation: none; }
}

.checkpoint-missed {
    background: var(--red-soft) !important;
    border-color: rgba(192, 57, 43, .35) !important;
    opacity: 1 !important;
}

.checkpoint-missed .checkpoint-time,
.checkpoint-missed .checkpoint-status {
    color: var(--red);
}

.checkpoint-item.completed {
    background: var(--green-soft) !important;
    border-color: rgba(22, 163, 74, .35) !important;
}

.checkpoint-item.completed .checkpoint-time,
.checkpoint-item.completed .checkpoint-status,
.checkpoint-item.completed .checkpoint-date {
    color: var(--green);
}

.checkpoint-item.completed.has-incident {
    background: var(--red-soft) !important;
    border-color: rgba(192, 57, 43, .35) !important;
}

.checkpoint-item.completed.has-incident .checkpoint-time,
.checkpoint-item.completed.has-incident .checkpoint-status,
.checkpoint-item.completed.has-incident .checkpoint-date {
    color: var(--red);
}

/* Отметка отправлена в офлайн-очередь, ждёт синхронизации — см.
   static/js/offline-queue.js. Отдельный (amber) от completed (green) и
   несделанного, чтобы не выглядело ни "готово", ни "пропущено". */
.checkpoint-item.queued {
    background: var(--amber-soft) !important;
    border-color: rgba(217, 119, 6, .35) !important;
    opacity: 1 !important;
}

.checkpoint-item.queued .checkpoint-time {
    color: var(--amber);
}

.checkpoint-item.queued .checkpoint-btn {
    background: var(--amber) !important;
    color: #fff !important;
    cursor: not-allowed !important;
}

/* ── Обход — независимый от меток присутствия тип меток ──────────────── */
.patrol-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    /* После "Начать обход"/"Отметить" сервер редиректит на #patrol-section
       (см. app.py), чтобы страница не сбрасывалась наверх — без этого отступа
       заголовок оказался бы под залипающей шапкой (.sticky-top). */
    scroll-margin-top: 120px;
}

.patrol-section h3 {
    font-size: 15px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 4px;
}

/* Полноэкранный режим активного обхода — #patrol-active-view (см.
   render_patrol_active в shift.html). Прячет весь остальной интерфейс
   смены под собой (opaque, во весь вьюпорт), не трогая его состояние —
   проще и надёжнее, чем реально скрывать десяток секций страницы. Ниже
   z-index сканера (.patrol-nfc-scan-overlay, 9100) и шторок-подтверждений
   (.sheet-overlay, 9000), чтобы они открывались поверх. */
.patrol-focus-overlay {
    display: none;
}

.patrol-focus-overlay.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: var(--surface);
    padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
}

.patrol-focus-hd {
    text-align: center;
    flex-shrink: 0;
}

.patrol-round-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.patrol-timer {
    font-size: 13px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--cobalt);
    margin-top: 2px;
}

.patrol-timer.patrol-timer-expired {
    color: var(--red);
}

.patrol-focus-progress {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.patrol-focus-progress svg {
    transform: rotate(-90deg);
}

.patrol-focus-progress svg circle {
    transition: stroke-dashoffset .3s ease;
}

.patrol-focus-progress-text {
    position: absolute;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.patrol-focus-list-label {
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted2);
    margin: 16px 0 8px;
    flex-shrink: 0;
}

.patrol-marks-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.patrol-mark-item {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    padding: 10px 14px;
    text-align: left;
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
}

.patrol-mark-label {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--ink);
}

.patrol-mark-status {
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 2px;
}

.patrol-mark-item.completed {
    background: var(--green-soft) !important;
    border-color: rgba(22, 163, 74, .35) !important;
}

.patrol-mark-item.completed .patrol-mark-label,
.patrol-mark-item.completed .patrol-mark-status {
    color: var(--green);
}

.patrol-mark-item.completed.has-incident {
    background: var(--red-soft) !important;
    border-color: rgba(192, 57, 43, .35) !important;
}

.patrol-mark-item.completed.has-incident .patrol-mark-label,
.patrol-mark-item.completed.has-incident .patrol-mark-status {
    color: var(--red);
}

/* Отметка отправлена в офлайн-очередь, ждёт синхронизации — см.
   static/js/offline-queue.js. */
.patrol-mark-item.queued {
    background: var(--amber-soft) !important;
    border-color: rgba(217, 119, 6, .35) !important;
}

.patrol-mark-item.queued .patrol-mark-label {
    color: var(--amber);
}

.patrol-mark-item.queued .patrol-mark-btn {
    background: var(--amber) !important;
    color: #fff !important;
    cursor: not-allowed !important;
}

.patrol-mark-status-pending {
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Метка ждёт NFC-скана (не завершена, есть UID) — вся строка кликабельна,
   открывает тот же сканер, что и кнопка «Считать метку» (см. shift.html). */
.patrol-mark-item[data-nfc-uid]:not(.completed) {
    cursor: pointer;
}

.patrol-history {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.patrol-history-title {
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin-bottom: 8px;
}

.patrol-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
}

.patrol-history-item:last-child {
    border-bottom: none;
}

.patrol-history-name {
    color: var(--ink);
    font-weight: 600;
}

.patrol-history-late {
    display: inline-flex;
    align-items: center;
    font-size: 10.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--amber);
    background: var(--amber-soft);
    border-radius: 20px;
    padding: 2px 7px;
    margin-left: 6px;
}

.patrol-history-partial {
    display: inline-flex;
    align-items: center;
    font-size: 10.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--red);
    background: var(--red-soft);
    border-radius: 20px;
    padding: 2px 7px;
    margin-left: 6px;
}

.patrol-history-time {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.patrol-end-link {
    margin-top: 12px;
    align-self: center;
    flex-shrink: 0;
    background: var(--red);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    padding: 9px 18px;
    cursor: pointer;
}

.patrol-end-link:active {
    opacity: .85;
}

.patrol-end-unmarked-list {
    margin: 8px 0 0;
    padding: 0 0 0 20px;
    font-size: 13.5px;
    color: var(--ink);
}

.patrol-end-unmarked-list li {
    margin-bottom: 3px;
}

.patrol-mark-btn {
    margin-top: 10px;
    width: 100%;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 650;
    background: var(--cobalt);
    color: #fff;
    cursor: pointer;
}

.patrol-start-scheduled {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
}

.patrol-slot-list {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Зелёная/оранжевая/красная плашка по каждому времени в расписании обхода —
   зелёная (пройден вовремя) и оранжевая (пройден с опозданием) выставляются
   сервером сразу при загрузке (см. app.py _patrol_slot_statuses), красная
   (просрочен — время + 15 минут истекло, а обход не пройден) может
   появиться и позже, по таймеру на этой же странице (см. checkScheduled). */
.patrol-slot {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 650;
    background: var(--surface-2);
    color: var(--muted);
}

.patrol-slot-ok {
    background: var(--green-soft);
    color: var(--green);
}

.patrol-slot-late {
    background: var(--amber-soft);
    color: var(--amber);
}

.patrol-slot-missed {
    background: var(--red-soft);
    color: var(--red);
}

.patrol-start-btn.due {
    animation: checkpointPulseUrgent 1.6s ease-in-out infinite;
}

/* ── NFC-метки обхода: одна кнопка «Считать метку» + полноэкранный сканер ── */
/* Главное (и самое частое) действие охранника во время обхода — сделан
   заметно ярче обычного .btn-primary (градиент teal→cobalt вместо плоского
   cobalt) и слегка пульсирует, чтобы взгляд сразу цеплялся за неё, а не за
   список меток вокруг. */
.patrol-nfc-scan-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    width: 100%;
    margin: 10px 0 16px;
    min-height: 78px;
    flex-shrink: 0;
    border: none;
    border-radius: 16px;
    padding: 18px;
    font-size: 21px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--teal), var(--cobalt));
    cursor: pointer;
    animation: patrolScanCtaPulse 2.2s ease-in-out infinite;
}

.patrol-nfc-scan-cta:active {
    animation: none;
    opacity: .9;
}

@keyframes patrolScanCtaPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14, 158, 138, .45), 0 4px 14px rgba(23, 85, 200, .22); }
    50% { box-shadow: 0 0 0 9px rgba(14, 158, 138, 0), 0 4px 14px rgba(23, 85, 200, .22); }
}

@media (prefers-reduced-motion: reduce) {
    .patrol-nfc-scan-cta {
        animation: none;
        box-shadow: 0 4px 14px rgba(23, 85, 200, .22);
    }
}

.patrol-nfc-scan-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 9100;
    flex-direction: column;
    background: radial-gradient(120% 100% at 50% 0%, #123f94, var(--navy) 78%);
    color: #fff;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 22px calc(28px + env(safe-area-inset-bottom, 0px));
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility 0s linear .22s;
}

.patrol-nfc-scan-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity .22s ease;
}

@media (prefers-reduced-motion: reduce) {
    .patrol-nfc-scan-overlay { transition: opacity .12s ease, visibility 0s linear .12s; }
    .patrol-nfc-scan-overlay.open { transition: opacity .12s ease; }
}

.patrol-nfc-scan-close {
    align-self: flex-end;
    width: 36px;
    height: 36px;
    min-height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.patrol-nfc-scan-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.patrol-nfc-scan-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    width: 100%;
}

/* .patrol-nfc-scan-state и [hidden] имеют одинаковую специфичность, но
   авторские правила всегда перебивают дефолтный user-agent [hidden] {
   display:none } — без этого override все три состояния сканера (ожидание/
   успех/ошибка) рендерились одновременно друг на друге. */
.patrol-nfc-scan-state[hidden] {
    display: none;
}

.patrol-nfc-rings {
    position: relative;
    width: 108px;
    height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.patrol-nfc-ring {
    position: absolute;
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .5);
    animation: patrolNfcPulse 2.2s ease-out infinite;
}

.patrol-nfc-ring:nth-child(2) { animation-delay: .7s; }
.patrol-nfc-ring:nth-child(3) { animation-delay: 1.4s; }

@keyframes patrolNfcPulse {
    0% { transform: scale(.35); opacity: .9; }
    100% { transform: scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .patrol-nfc-ring { animation: none; opacity: .3; }
}

.patrol-nfc-ring-icon {
    position: relative;
    z-index: 1;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.patrol-nfc-scan-title {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.patrol-nfc-scan-sub {
    margin: -4px 0 0;
    font-size: 13.5px;
    opacity: .78;
    max-width: 260px;
    line-height: 1.5;
}

.patrol-nfc-scan-progress {
    font-size: 12px;
    font-weight: 650;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .14);
    font-variant-numeric: tabular-nums;
}

.patrol-nfc-success-circle,
.patrol-nfc-error-circle {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    animation: patrolNfcPop .35s cubic-bezier(.34, 1.56, .64, 1);
}

@media (prefers-reduced-motion: reduce) {
    .patrol-nfc-success-circle, .patrol-nfc-error-circle { animation: none; }
}

@keyframes patrolNfcPop {
    from { transform: scale(.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.patrol-nfc-success-circle { background: var(--green); color: #fff; }
.patrol-nfc-error-circle { background: var(--red); color: #fff; }

.patrol-nfc-scan-mark-name {
    font-size: 14px;
    font-weight: 650;
    padding: 5px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .16);
}

.patrol-nfc-retry-btn {
    margin-top: 4px;
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-size: 14px;
    font-weight: 650;
    background: #fff;
    color: var(--cobalt);
    cursor: pointer;
}

.nfc-setup-section .sub {
    margin-bottom: 12px;
}

.nfc-mark-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nfc-mark-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.nfc-mark-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.nfc-mark-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.nfc-mark-status.paired {
    color: var(--green);
}

.checkpoint-situation {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, .06);
    font-size: 12px;
    text-align: left;
}

.checkpoint-situation-ok {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--green);
    font-weight: 600;
}

.checkpoint-situation-incident-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--red);
    font-weight: 650;
}

.checkpoint-situation-incident-desc {
    margin-top: 4px;
    color: var(--ink);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ── Toggle button (end_shift.html) ────────────────────────────────────── */
.btn-toggle {
    width: 100%;
    min-height: 48px;
    padding: 14px 20px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 650;
    cursor: pointer;
}

.btn-toggle.checked {
    background: var(--green-soft);
    color: var(--green);
    border-color: var(--green);
}

/* ── Detentions ─────────────────────────────────────────────────────────── */
.detention-list-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--red);
    margin-bottom: 10px;
}

.detention-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--surface-2);
}

.detention-item:last-child { margin-bottom: 0; }

.detention-desc {
    font-size: 13.5px;
    color: var(--ink);
    line-height: 1.4;
    margin-bottom: 6px;
}

.detention-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detention-amount {
    font-size: 14px;
    font-weight: 700;
    color: var(--red);
}

.detention-time {
    font-size: 12px;
    color: var(--muted2);
}

/* ── Sticky bottom action bar (ЧП / Задержание / КТС) ──────────────────── */
.bottombar {
    position: sticky;
    bottom: 0;
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

/* 3 кнопки — ЧП переносим вниз и делаем во всю ширину, остальные две — в верхнем ряду.
   4 кнопки — ровно 2 ряда по 2. Класс .n3/.n4 проставляется сервером по факту того,
   сколько кнопок реально показываются (см. bottombar_button_count в shift.html). */
.bottombar.n3 .action-btn:not(:first-child) {
    flex-basis: 40%;
}
.bottombar.n3 .action-btn:first-child {
    order: 1;
    flex-basis: 100%;
}
.bottombar.n4 .action-btn {
    flex-basis: 40%;
}

.action-btn, .emergency-button, .detention-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    border-radius: 12px;
    min-height: 50px;
    padding: 13px 0;
    font-size: 14.5px;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
}

.emergency-button, .action-btn.emergency { background: var(--red-soft); color: var(--red); }
.detention-button, .action-btn.detention { background: var(--amber-soft); color: var(--amber); }
.action-btn.kts { background: var(--red-soft); color: var(--red); }
.action-btn.chief-call { background: var(--amber-soft); color: var(--amber); }

/* ── Bottom sheet (mobile modal) ────────────────────────────────────────── */
/* Открытие/закрытие через прозрачность + сдвиг панели, а не мгновенный
   display:none↔flex — шторка физически выезжает снизу, а не появляется
   рывком. display остаётся flex всегда: у него нет промежуточного
   состояния, из которого можно плавно анимировать. Когда закрыта —
   visibility:hidden (не в таб-порядке, не читается скринридером), но сам
   переход в hidden отложен на длительность transition, чтобы анимация
   успела доиграть (см. transition: ..., visibility 0s .22s ниже). */
.sheet-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, .45);
    z-index: 9000;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility 0s linear .22s;
}

.sheet-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity .22s ease;
}

.sheet {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 30px rgba(10, 22, 40, .18);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.22, .8, .22, 1);
}

.sheet-overlay.open .sheet {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .sheet-overlay { transition: opacity .15s ease, visibility 0s linear .15s; }
    .sheet-overlay.open { transition: opacity .15s ease; }
    .sheet { transition: none; }
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 6px auto 14px;
}

/* Только у «Ситуации на объекте» ручка тянется по-настоящему (см. JS ниже
   по странице) — увеличиваем тап-зону под палец, оставляя саму полоску
   визуально прежней (padding + background-clip: content-box). */
#situationModal .sheet-handle {
    touch-action: none;
    cursor: grab;
    padding: 12px 50px;
    margin: -8px auto 2px;
    background-clip: content-box;
}

.sheet h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 650;
    color: var(--ink);
}

.sheet .sub {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 18px;
}

.sheet label {
    font-size: 12.5px;
    font-weight: 650;
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
}

.sheet textarea, .sheet input {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface-2);
    margin-bottom: 14px;
    resize: vertical;
}

.sheet-warn {
    margin: -6px 0 14px;
    background: var(--amber-soft);
    border: 1px solid rgba(217, 119, 6, .3);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
    color: var(--amber);
}

.sheet-actions {
    display: flex;
    gap: 10px;
}

.sheet-actions button {
    flex: 1;
    min-height: 48px;
    border: none;
    border-radius: 10px;
    padding: 13px 0;
    font-size: 15px;
    font-weight: 650;
    cursor: pointer;
}

.sheet-cancel { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.sheet-submit { background: var(--red); color: #fff; }

/* ── Full-screen dialogs (PDF viewer, confirmation modals) ─────────────── */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, .5);
    z-index: 9998;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dialog-overlay.flex { display: flex; }
.dialog-overlay.block { display: block; padding: 20px; }

.dialog-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 30px 26px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
}

.dialog-icon { font-size: 44px; margin-bottom: 14px; }

.dialog-box h3 {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 650;
    color: var(--ink);
}

.dialog-box p {
    color: var(--muted);
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.5;
}

.dialog-box .btn-primary { width: 100%; }


/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 4px;
    font-size: 13.5px;
}

.alert-success {
    background: var(--green-soft);
    color: var(--green);
    border-left: 4px solid var(--green);
}

.alert-error {
    background: var(--red-soft);
    color: var(--red);
    border-left: 4px solid var(--red);
}

/* ── Toast: короткое авто-исчезающее подтверждение (вместо постоянного alert) */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    max-width: calc(100% - 32px);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 650;
    text-align: center;
    color: #fff;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    animation: toastPop 2.6s ease forwards;
}

.toast-success { background: var(--green); }

@keyframes toastPop {
    0%   { opacity: 0; transform: translate(-50%, 10px); }
    10%  { opacity: 1; transform: translate(-50%, 0); }
    82%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -8px); }
}

@media (prefers-reduced-motion: reduce) {
    .toast { animation: toastFade 2.6s ease forwards; transform: translate(-50%, 0); }
}

@keyframes toastFade {
    0%, 82% { opacity: 1; }
    100% { opacity: 0; }
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 36px 28px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 22px;
    color: var(--ink);
    margin-bottom: 6px;
    font-weight: 700;
}

.login-header p {
    color: var(--muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 650;
    color: var(--muted);
    font-size: 13px;
}

.form-group input {
    width: 100%;
    padding: 14px;
    min-height: 48px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--surface-2);
    color: var(--ink);
}

.form-group input:focus {
    outline: none;
    border-color: var(--cobalt);
    box-shadow: 0 0 0 3px rgba(23, 85, 200, .12);
}

.footer-text {
    text-align: center;
    margin-top: 22px;
    color: var(--muted2);
    font-size: 12.5px;
}

.lang-toggle-standalone {
    display: flex;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    margin-bottom: 18px;
}

.lang-toggle-standalone a { color: var(--muted2); text-decoration: none; padding: 4px; }
.lang-toggle-standalone a.active { color: var(--cobalt); }
.lang-toggle-standalone span { color: var(--border); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 40px 20px;
    border-radius: 14px;
    text-align: center;
    color: var(--muted);
}

.empty-state p:first-child {
    font-size: 16px;
    color: var(--ink);
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state p { font-size: 13.5px; }

/* ── Pending problem review (step 0) ───────────────────────────────────── */
.prev-problem-card {
    background: var(--red-soft);
    border: 1px solid rgba(192, 57, 43, .25);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.prev-problem-badge {
    background: var(--red);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
}

.prev-problem-meta {
    font-size: 11.5px;
    color: var(--muted2);
}

.prev-problem-desc {
    font-size: 13.5px;
    color: var(--ink);
    margin: 10px 0;
}

.prev-problem-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.prev-problem-actions label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    min-height: 32px;
}

.radio-confirm { color: var(--red); }
.radio-confirm input { accent-color: var(--red); width: 17px; height: 17px; }

.radio-resolve { color: var(--green); }
.radio-resolve input { accent-color: var(--green); width: 17px; height: 17px; }

.prev-answer-note {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
    color: var(--ink);
    margin-bottom: 10px;
    white-space: pre-wrap;
    line-height: 1.5;
}

.confirmed-note {
    color: var(--green);
    font-weight: 650;
    text-align: center;
    padding: 8px;
    font-size: 13px;
}
