/* Shus.pro — минималистичный дружелюбный интерфейс, mobile-first */

:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1c2733;
    --muted: #6b7684;
    --line: #e3e8ee;
    --brand: #12b76a;
    --brand-dark: #0e9a58;
    --brand-soft: #e6f7ee;
    --danger: #e5484d;
    --warn: #f5a623;
    --info: #2f80ed;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.45;
}

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

.page {
    max-width: 860px;
    margin: 0 auto;
    /* Нижний отступ — по реальной высоте плавающего меню (--nav-h из JS). */
    padding: 14px 14px calc(var(--nav-h, 86px) + 26px + env(safe-area-inset-bottom));
}

/* ---------- Шапка ---------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    /* Бренд прижат влево — это «шапка страницы», а не отдельный плавающий блок. */
    justify-content: flex-start;
    padding: 10px 18px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    font-size: 19px;
    color: var(--ink);
    letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.logo {
    width: 60px;
    height: 60px;
    max-width: 60px;    /* страховка: без CSS картинка 256px растянула бы шапку */
    max-height: 60px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    flex: none;
}
.topbar-client { padding: 10px 14px; }
.client-branding-header { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.client-branding-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-branding-logo { width: 48px; height: 48px; flex: none; object-fit: contain; border-radius: 10px; background: #fff; }
.client-branding-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.client-branding-name { color: var(--ink); font-size: 16px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.client-branding-phone { color: var(--muted); font-size: 14px; font-weight: 600; }
.client-branding-phone:hover { color: var(--brand-dark); text-decoration: none; }
.company-context-switcher {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 18px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}
.company-context-switcher form {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 824px;
    margin: 0 auto;
}
.company-context-switcher label {
    flex: none;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.company-context-switcher select {
    flex: 1;
    min-width: 0;
    max-width: 500px;
    margin: 0;
    padding: 8px 34px 8px 10px;
}
.company-context-switcher p {
    width: 100%;
    max-width: 824px;
    margin: 1px auto 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

/* ---------- Нижнее меню ---------- */
.bottomnav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
    box-shadow: 0 -4px 16px rgba(16,24,40,.06);
}
.bottomnav-link {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.bottomnav-link:hover { text-decoration: none; color: var(--ink); }
.bottomnav-link .ic { font-size: 20px; line-height: 1; }
.bottomnav-link.active { color: var(--brand-dark); }
.bottomnav-link.active .ic { transform: translateY(-1px); }
.dot {
    position: absolute;
    top: 7px;
    right: calc(50% - 16px);
    width: 9px;
    height: 9px;
    background: var(--danger);
    border: 2px solid #fff;
    border-radius: 50%;
}
.dot-blink {
    animation: dotPulse 1.05s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(217, 45, 32, .55);
}
@keyframes dotPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 45, 32, .55); opacity: 1; }
    50% { transform: scale(1.35); box-shadow: 0 0 0 6px rgba(217, 45, 32, 0); opacity: .55; }
}

/* ---------- Карточки и сетки ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 17px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}
.list-item:hover { text-decoration: none; border-color: #cfe3d9; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; }
.list-item .sub { color: var(--muted); font-size: 13.5px; }

/*
 * Подсветка срочности в списках заявок.
 * Тона намеренно приглушённые: заливка отличает строку, но не бьёт по глазам
 * и не мешает читать текст. Слева — цветная полоса как основной сигнал.
 */
.list-item.urg-high {
    background: #fdf3f3;
    border-color: #f0cfd0;
    box-shadow: inset 3px 0 0 #d98b8e, var(--shadow);
}
.list-item.urg-high:hover { background: #fbebeb; border-color: #e6bcbe; }

.list-item.urg-medium {
    background: #fdf5f7;
    border-color: #f2d7de;
    box-shadow: inset 3px 0 0 #e3a9b8, var(--shadow);
}
.list-item.urg-medium:hover { background: #fbeef1; border-color: #ebc7d1; }

/* Тег срочности в карточке заявки. */
.urg-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; }
.urg-tag-high { background: #fbeaea; color: #9c4a4d; }
.urg-tag-medium { background: #fbeef2; color: #9c4a68; }
.urg-tag-low { background: transparent; color: inherit; padding: 0; }

/* Строка смены срочности: подпись, селект и кнопка в один ряд. */
.urgency-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 14px; }
.urgency-form label { margin: 0; color: var(--muted); font-size: 13.5px; }
.urgency-form select { width: auto; min-width: 150px; margin: 0; }

/*
 * Кнопка «прокрутить вниз». Живёт над полем ввода, появляется только когда
 * лента отмотана вверх. Позиционируется относительно .chat-app, поэтому
 * остаётся на месте при прокрутке ленты.
 */
.chat-scroll-down {
    position: absolute;
    right: 14px;
    /* Держится над полем ввода, которое стоит над меню. */
    bottom: calc(var(--nav-h, 84px) + 60px);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .16);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity .18s, transform .18s, visibility .18s;
    z-index: 20;
    padding: 0;
}
.chat-scroll-down.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.chat-scroll-down:hover { background: #f3f6f9; }
.chat-scroll-down svg { width: 20px; height: 20px; }

/* Счётчик новых сообщений на кнопке — видно, что внизу что-то пришло. */
.chat-scroll-down-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 19px;
    text-align: center;
    border: 2px solid var(--card);
}

/* Подсказка над полем ввода в чате (антифлуд и подобные сообщения). */
.composer-hint {
    display: none;
    margin: 0 0 8px;
    padding: 7px 12px;
    border-radius: 10px;
    background: #fdf3f3;
    border: 1px solid #f0cfd0;
    color: #9c4a4d;
    font-size: 13.5px;
}
.composer-hint.is-visible { display: block; }

/*
 * Поля выбора файла на узких экранах.
 * У <input type="file"> собственная внутренняя ширина (имя файла + кнопка
 * «Обзор»), которая НЕ сжимается: даже с flex:1 элемент упирается в свой
 * min-content и растягивает страницу — появлялась горизонтальная прокрутка,
 * а .bottomnav (left:0;right:0) растягивался следом и уезжал за экран.
 * min-width:0 разрешает flex-элементу сжиматься, max-width — страховка вне flex.
 */
input[type="file"] {
    min-width: 0;
    max-width: 100%;
}

/*
 * Общая страховка от горизонтальной прокрутки: длинные слова, URL и широкие
 * поля не должны раздвигать страницу на телефоне.
 */
html, body { overflow-x: hidden; }

/* Установка приложения: пошаговая инструкция для iPhone. */
.install-steps {
    margin: 4px 0 0;
    padding-left: 22px;
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.9;
}

/*
 * Полоска «Установить приложение» над нижним меню.
 * Отступ снизу считается от реальной высоты меню (--nav-h), иначе на устройствах
 * с большой safe-area она залезала бы под меню.
 */
.install-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--nav-h, 84px) + 12px + env(safe-area-inset-bottom));
    z-index: 45;                 /* ниже меню (50), выше контента */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(16, 24, 40, .14);
}
.install-bar[hidden] { display: none; }
.install-bar-icon { font-size: 20px; flex: none; }
.install-bar-text {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    /* В одну строку: на узких экранах текст иначе разъезжается на три строки. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.install-bar .btn { flex: none; white-space: nowrap; }
.install-bar-close {
    flex: none;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
}
.install-bar-close:hover { background: #eef1f4; color: var(--ink); }

/* На широких экранах полоска не растягивается на всю ширину. */
@media (min-width: 720px) {
    .install-bar { left: auto; right: 24px; width: 380px; }
}

/* Настройки уведомлений. */
.push-row { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; font-weight: 400; font-size: 15px; color: var(--ink); cursor: pointer; }
.push-status { font-size: 13.5px; margin: 0 0 10px; color: var(--muted); }
.push-status-ok { color: #0e7a4a; }
.push-status-warn { color: #9c4a4d; }

/* Блок удаления аккаунта — визуально отделён как опасная зона. */
.card-danger { border-color: #f0cfd0; }
.card-danger > h2 { color: #9c4a4d; }
.del-list { margin: 0 0 4px; padding-left: 20px; color: var(--ink); font-size: 14.5px; line-height: 1.7; }
.del-list-keep { color: var(--muted); }

/* Список выбора галочками (объекты в группе, приглашения). */
.check-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 4px;
}
.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 7px 4px;
    font-weight: 400;
    font-size: 14.5px;
    color: var(--ink);
    cursor: pointer;
    border-radius: 8px;
}
.check-row:hover { background: #f3f6f9; }
.check-row input { flex: none; margin: 0; }
.registration-profile-block {
    margin: 18px 0 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface, #fff);
}
.registration-profile-block h3 { margin-top: 0; }
.registration-subgroup {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0;
    padding: 6px 0 6px 12px;
    border-left: 2px solid var(--line);
}
.registration-subgroup-title { margin: 0 0 2px; color: var(--muted); font-size: 13.5px; font-weight: 700; }
.registration-profile-block [data-required-message] {
    width: 100%;
    margin: 4px 0 2px;
    color: #a33;
    font-size: 13px;
}

/* Постраничная навигация под списками. */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.pager .muted { font-size: 13.5px; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f1f4f7; color: var(--ink); }
.btn-danger { background: #fdecec; color: var(--danger); }
.btn-danger:hover { background: #f9d9d9; color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 13.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Формы ---------- */
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
input[type=tel], select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ---------- Флеш-сообщения ---------- */
.flash {
    border-radius: 10px;
    padding: 11px 14px;
    margin-bottom: 12px;
    font-size: 14.5px;
    border: 1px solid var(--line);
    background: #fff;
}
.flash-success { background: var(--brand-soft); border-color: #bfe8d0; color: #0b6e41; }
.flash-error { background: #fdecec; border-color: #f5c6c8; color: #9c1c21; }
.flash-info { background: #eaf2fe; border-color: #c7dbf9; color: #1d5bb8; }

/* ---------- Роли и статусы ---------- */
.role-pill, .pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #eef1f4;
    color: var(--muted);
}
.role-owner { background: #fdf1e3; color: #b26a00; }
.role-engineer { background: #eaf2fe; color: #1d5bb8; }
.role-installer { background: #e6f7ee; color: #0b6e41; }
.role-technician { background: #f3e8fd; color: #6d28d9; }
.role-specialist { background: #eef2f7; color: #344054; }
.role-client { background: #eef1f4; color: #4a5561; }

.st { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.st-new { background: #eaf2fe; color: #1d5bb8; }
.st-taken { background: #fdf1e3; color: #b26a00; }
.st-in_work { background: #f3e8fd; color: #6d28d9; }
.st-done { background: #e6f7ee; color: #0b6e41; }
.st-cancelled { background: #fdecec; color: #9c1c21; }
.st-awaiting { background: #fdf1e3; color: #b26a00; }
.st-planned { background: #e8f4fd; color: #0e6f9c; }

/* ---------- Чаты: список ---------- */
/* Группы в списке чатов: общие / объекты / заявки */
.chat-group { margin-bottom: 18px; }
.chat-group-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 4px 8px;
}
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    color: inherit;
}
.chat-row:hover { text-decoration: none; border-color: #cfe3d9; }
.chat-row-icon { font-size: 22px; flex: none; }
.chat-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top { display: flex; align-items: baseline; gap: 8px; }
.chat-row-title {
    font-weight: 700;
    font-size: 15px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-row-time { color: var(--muted); font-size: 12px; flex: none; }
.chat-row-preview { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Чат-мессенджер (полный экран) ---------- */
body.has-chat-app { overflow: hidden; }
.chat-app {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;      /* учитывает адресную строку мобильного браузера */
    /*
     * --app-h выставляется из JS по visualViewport. В установленном приложении
     * (standalone) и при открытой клавиатуре dvh обновляется не везде и не сразу,
     * поэтому реальную высоту берём из JS, а dvh оставляем запасным вариантом.
     */
    height: var(--app-h, 100dvh);
    min-height: 0;
    z-index: 40; /* ниже нижнего меню (50), выше остального */
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.chat-topbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    z-index: 2;
}
.chat-back {
    font-weight: 700;
    font-size: 15px;
    color: var(--brand-dark);
    white-space: nowrap;
}
.chat-back:hover { text-decoration: none; }
.chat-title { min-width: 0; flex: 1; }
.chat-title-name { font-weight: 800; font-size: 16px; line-height: 1.2; }
.chat-title-sub {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-title-sub a { color: var(--muted); }
.chat-title-sub a.on { color: var(--brand-dark); font-weight: 700; }
.chat-title-sub.chat-meta-row { display: flex; align-items: center; gap: 9px; overflow: visible; white-space: normal; }
.chat-context-link { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-participants-details { position: relative; flex: none; z-index: 3; color: var(--brand-dark); }
.chat-participants-details > summary { cursor: pointer; list-style: none; font-size: 12px; font-weight: 800; white-space: nowrap; }
.chat-participants-details > summary::-webkit-details-marker { display: none; }
.chat-participants-details > summary::after { content: " ▾"; font-size: 10px; }
.chat-participants-details[open] > summary::after { content: " ▴"; }
.chat-participants-popover { position: absolute; top: calc(100% + 9px); right: 0; width: min(290px, calc(100vw - 28px)); max-height: min(55vh, 420px); overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); box-shadow: 0 12px 32px rgba(15, 23, 42, .2); z-index: 30; }
.chat-participants-heading { margin: 0 0 9px; font-size: 13px; font-weight: 900; }
.chat-participants-list { display: flex; flex-direction: column; gap: 4px; }
.chat-participant-row { display: flex; align-items: center; gap: 9px; min-height: 40px; font-size: 13px; font-weight: 700; }
.chat-participant-row .avatar { flex: none; width: 34px; height: 34px; }
.chat-title-name .nav-ic,
.chat-row-icon .nav-ic {
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: -5px;
    color: #4a545f;
}
.chat-notify-toggle {
    flex: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #f7f9fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.chat-notify-toggle.is-on { color: #6f8fa7; background: #eef5f8; border-color: #d8e5ec; }
.chat-notify-toggle.is-muted { color: #8a96a3; background: #f1f3f5; border-color: #e0e5ea; }
.chat-notify-toggle:disabled { opacity: .65; cursor: default; }
.chat-notify-toggle svg {
    width: 21px;
    height: 21px;
    display: block;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.chat-scroll {
    flex: 1 1 auto;
    min-height: 0;   /* ключевое: без этого лента распирает контейнер и поле ввода уезжает за экран */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;

    /*
     * Тематический фон-подложка, как в мессенджерах: неяркий узор из значков
     * (камеры, инструменты, замки). Не скроллится вместе с лентой —
     * background-attachment: local прокручивал бы его, поэтому фон закреплён.
     */
    background-color: #eef1f4;
    /*
     * SVG-плитка: значки крупные и раскиданы вразнобой (не рядами), при этом
     * файл ~3.5 КБ вместо 78 КБ у растрового варианта и не мылится на Retina.
     */
    background-image: url('chat-bg.svg');
    background-repeat: repeat;
    background-size: 520px auto;   /* натуральный размер плитки */
    /*
     * scroll (а не fixed): фон привязан к самому блоку ленты и не едет вместе
     * с сообщениями. fixed привязал бы его к окну и ломался бы на iOS Safari.
     */
    background-attachment: scroll;
    background-position: center;
}
.chat-day {
    align-self: center;
    background: rgba(107,118,132,.14);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 12px;
    margin: 10px 0 4px;
}
.chat-composer {
    flex: none;
    /*
     * Столбец: панель ответа, превью фото и строка ввода идут друг под другом.
     * Раньше здесь была строка — из-за неё .composer-row сжималась и поле ввода
     * занимало лишь часть ширины.
     */
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    /*
     * Нижний отступ = реальная высота плавающего меню (+ запас), измеряется в JS
     * и кладётся в --nav-h. Раньше здесь было жёсткое 84px: в установленном
     * приложении safe-area больше, меню выше — и поле ввода пряталось за меню.
     */
    padding-bottom: calc(var(--nav-h, 84px) + 12px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--line);
}
.chat-composer > * { width: 100%; }
.chat-readonly-notice { margin: 0; color: var(--muted); text-align: center; font-size: 14px; }

/* Строка сообщения: аватар сбоку от «пузыря» (слева у чужих, справа у своих). */
.msg { display: flex; align-items: flex-end; gap: 7px; max-width: 88%; }
.msg-bubble {
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; font-weight: 600; display: block; }
/* Имя автора окрашено в постоянный оттенок, закреплённый за его ID. */
.msg .msg-head .chat-user-name { color: hsl(var(--chat-user-hue), 62%, 29%); }
.msg.mine { align-self: flex-end; flex-direction: row; }
.msg.mine .msg-bubble { background: var(--brand); color: #fff; }
.msg.other { align-self: flex-start; }
/*
 * Чужие сообщения: белая подложка с мягкой рамкой и тенью.
 * Раньше здесь был #eef1f4 — ровно цвет фона ленты, из-за чего пузырь
 * сливался с подложкой и сообщение читалось как текст «на фоне».
 */
.msg.other .msg-bubble {
    background: #ffffff;
    border: 1px solid #dfe5ec;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.msg.system { align-self: center; max-width: 92%; }
.msg.system .msg-bubble { background: #fdf6e3; color: #8a6d1a; font-size: 13px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.tab {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 700;
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
}
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Аватары ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: #e3e8ee;
    color: #96a1ad;
    flex: none;
    vertical-align: middle;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; max-width: 100%; max-height: 100%; }
.avatar svg { width: 58%; height: 58%; }
.avatar.avatar-sil { background: #e3e8ee; }
.msg .avatar.avatar-sil.chat-user-avatar {
    background: hsl(var(--chat-user-hue), 72%, 91%);
    color: hsl(var(--chat-user-hue), 62%, 39%);
}

/* Страховка: аватар в сообщении всегда маленький кружок, даже если фото большое. */
.msg .avatar { width: 32px; height: 32px; min-width: 32px; min-height: 32px; flex: 0 0 32px; align-self: flex-end; }
.msg .avatar img { width: 32px; height: 32px; object-fit: cover; border-radius: 50%; }

.staff-cell { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: none; }

/* ---------- Сообщения: вложенные элементы ---------- */
.msg-head { margin-bottom: 3px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px 7px; }
.moderator-badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid #b8e0c4;
    border-radius: 999px;
    padding: 1px 7px;
    background: #eaf7ed;
    color: #217344;
    font-size: 10px;
    line-height: 1.5;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
}
.msg.mine .moderator-badge { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.4); color: #fff; }
.msg-body { min-width: 0; }
.msg-photo { display: block; margin-top: 6px; }
.msg-photo img {
    max-width: 240px;
    max-height: 240px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.06);
    display: block;
}
/*
 * Фото в процессе отправки: локальное превью приглушено, поверх — колесико.
 * Показывается, пока файл идёт на сервер (на медленной связи это секунды).
 */
.msg-photo-pending { position: relative; display: inline-block; }
.msg-photo-pending img { opacity: .55; filter: saturate(.7); }
.msg-pending .msg-bubble { opacity: .9; }

.photo-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 3px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: photoSpin .8s linear infinite;
    /* Тень, чтобы колесико было видно и на светлом снимке. */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}
@keyframes photoSpin { to { transform: rotate(360deg); } }

/* Уважаем системную настройку «уменьшить движение». */
@media (prefers-reduced-motion: reduce) {
    .photo-spinner { animation-duration: 2s; }
}

.msg-bubble { position: relative; }

/* ---------- Действия над сообщением: долгое нажатие вместо крестика ---------- */

/*
 * Долгое нажатие не должно выделять текст и вызывать системное меню браузера
 * («Выделить / Копировать / Поиск»). Нужны все свойства сразу:
 *   touch-callout   — гасит всплывашку iOS Safari;
 *   user-select     — запрещает выделение (в т.ч. -moz-/-ms- для старых движков);
 *   tap-highlight   — убирает серую подсветку Android Chrome.
 * Правило вешаем и на потомков: Android умеет выделять вложенный текст в обход родителя.
 */
.msg,
.msg * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
/* Ссылки и фото внутри сообщения остаются кликабельными. */
.msg a,
.msg img { -webkit-touch-callout: none; }
/* Пока открыто меню — блокируем выделение по всей странице. */
body.msg-menu-open,
body.msg-menu-open * {
    -webkit-user-select: none !important;
    user-select: none !important;
}
.msg.msg-active .msg-bubble {
    outline: 2px solid rgba(37, 99, 235, .55);
    outline-offset: 1px;
}

/* Подсветка сообщения, к которому перешли по клику на цитату. */
@keyframes msgFlash {
    0%, 65% { box-shadow: 0 0 0 3px rgba(37, 99, 235, .45); }
    100%    { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0); }
}
.msg.msg-flash .msg-bubble {
    animation: msgFlash 1.6s ease-out;
    border-radius: 14px;
}

.msg-menu {
    position: fixed;
    z-index: 1200;
    min-width: 172px;
    padding: 6px;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.msg-menu-item {
    background: none;
    border: none;
    text-align: left;
    font: inherit;
    font-size: 15px;
    color: #1f2937;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
}
.msg-menu-item:hover,
.msg-menu-item:focus-visible { background: #f1f5f9; }
.msg-menu-item.danger { color: #c62828; }

.mod-info-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, .52);
}
.mod-info-dialog {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    color: #172033;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
}
.mod-info-dialog h2 { margin: 0 0 16px; font-size: 18px; }
.mod-info-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid #edf0f4; font-size: 14px; }
.mod-info-row strong { color: #64748b; }
.mod-info-row span { overflow-wrap: anywhere; }
.mod-info-dialog > .btn { width: 100%; margin-top: 16px; }

/* ---------- Цитата в сообщении ---------- */
.msg-quote {
    display: block;
    border-left: 3px solid rgba(37, 99, 235, .6);
    padding: 2px 0 2px 8px;
    margin-bottom: 5px;
    font-size: 13px;
    line-height: 1.35;
    opacity: .85;
}
.msg-quote { cursor: pointer; border-radius: 0 6px 6px 0; transition: background .15s; }
.msg-quote:hover { background: rgba(37, 99, 235, .08); }
.msg.mine .msg-quote:hover { background: rgba(255, 255, 255, .16); }
.msg-quote-name { display: block; font-weight: 600; }
.msg-quote-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}
.msg.mine .msg-quote { border-left-color: rgba(255,255,255,.75); }

/* ---------- Панель «Ответ на сообщение» над полем ввода ---------- */
.chat-reply {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 6px;
    background: #eef2f7;
    border-left: 3px solid #2563eb;
    border-radius: 8px;
}
.chat-reply[hidden] { display: none; }
.chat-reply-info { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; }
.chat-reply-name { display: block; font-weight: 600; color: #2563eb; }
.chat-reply-text {
    display: block;
    color: #4b5563;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-reply-x {
    background: none;
    border: none;
    font-size: 16px;
    color: #6b7280;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    flex: none;
}

/* ---------- Поле ввода с фото ---------- */
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row .chat-message-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    max-height: 108px; /* примерно 4 строки */
    line-height: 20px;
    padding: 11px 12px;
    resize: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    overflow-x: hidden;
    overflow-y: hidden;
    box-sizing: border-box;
}
.composer-row .chat-message-input.is-overflowing { overflow-y: auto; }
.composer-attach {
    flex: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    font-size: 18px;
    cursor: pointer;
}
.composer-preview { position: relative; margin-bottom: 8px; }
.composer-preview img {
    max-height: 130px;
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    display: block;
}
.composer-preview-x {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 13px;
    cursor: pointer;
}

/* ---------- Шапка заявки внутри чата (тема, описание, фото) ---------- */
.ticket-head {
    flex: none;
    align-self: stretch;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 6px;
    box-shadow: var(--shadow);
}
.ticket-head-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ticket-head-type { color: var(--muted); font-size: 13px; font-weight: 600; }
.ticket-head-title { font-weight: 800; font-size: 16px; line-height: 1.25; }
.ticket-head-desc { color: #33404e; font-size: 14.5px; margin-top: 6px; white-space: normal; }
.ticket-head-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ticket-head-photos img {
    width: 84px; height: 84px; object-fit: cover;
    border-radius: 10px; border: 1px solid var(--line); display: block; cursor: zoom-in;
}
.ticket-head-link { display: inline-block; margin-top: 10px; font-size: 14px; font-weight: 700; }

/* Завершённые заявки в списке чатов — приглушённо */
.chat-row-closed { background: #eef1f4; opacity: .75; }
.chat-row-closed .chat-row-title { color: var(--muted); }

/* ---------- Счётчик непрочитанных ---------- */
.chat-badge {
    flex: none;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 8px;
    line-height: 18px;
}
.chat-badge-muted { background: #6b7280; }

/* ---------- Поиск ---------- */
.search-form { display: flex; gap: 8px; margin-bottom: 12px; }
.search-form input { flex: 1; }

/* Кнопка поиска — серая лупа, а не заливная кнопка: она вторична рядом с полем. */
.search-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    transition: background .15s, color .15s, border-color .15s;
}
.search-btn svg { width: 20px; height: 20px; }
.search-btn:hover { background: #eef1f4; color: var(--ink); border-color: #cfd6dd; }
.snippet { color: var(--ink); font-size: 14px; }

/* ---------- Профиль: аватар и оформление ---------- */
.profile-avatar-row { display: flex; gap: 14px; align-items: flex-start; }
.profile-avatar-actions { flex: 1; min-width: 0; }
.radio-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
}
.radio-row input { width: auto; margin: 0; }

/* Строка с галочкой (например, в «Настройках про»). */
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
}
.check-row input { width: auto; margin: 2px 0 0; flex: none; }
.check-row input:disabled + span { opacity: .6; }
.radio-row input:disabled + span { opacity: .6; }

/* ---------- Значки меню (тема «современная») ---------- */
.nav-ic { width: 22px; height: 22px; color: #4a545f; }  /* графит */
.bottomnav-link.active .nav-ic { color: var(--brand-dark); }
.bottomnav-link .ic { display: inline-flex; align-items: center; justify-content: center; height: 22px; }

/* ---------- Фото заявки ---------- */
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.photo-item { position: relative; }
.photo-item a.js-lightbox { display: inline-block; cursor: zoom-in; }
.photo-item .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 6px; font-size: 12px; padding: 2px 6px; cursor: pointer; }

/* ---------- Лайтбокс ---------- */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(10,14,20,.9);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 18px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox-close {
    position: absolute; top: 14px; right: 14px;
    background: rgba(255,255,255,.18); color: #fff; border: none;
    border-radius: 50%; width: 42px; height: 42px; font-size: 18px; cursor: pointer;
}

/* ---------- Прочее ---------- */
.muted { color: var(--muted); font-size: 14px; }
.hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.inline { display: inline; }
.item-dot { width: 10px; height: 10px; background: var(--danger); border-radius: 50%; flex: none; margin-left: 4px; animation: dotPulse 1.05s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(217,45,32,.55); }

/* ---------- Раскрывающийся блок «Добавить объект» ---------- */
details.toggler { margin-bottom: 14px; }
details.toggler > summary { cursor: pointer; list-style: none; display: inline-flex; }
details.toggler > summary::-webkit-details-marker { display: none; }
details.toggler > .card { margin-top: 12px; }

/* ---------- Шапка раздела: заголовок и кнопка «+» напротив него ---------- */
/* Шапка может быть <summary> — убираем стрелку-маркер и делаем её flex-строкой. */
summary.page-head {
    cursor: default;
    list-style: none;
    display: flex;
}
summary.page-head::-webkit-details-marker { display: none; }
summary.page-head::marker { content: ''; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
}
.page-head h1,
.page-head h2 { margin: 0; }

/* Круглая кнопка «+»: раскрывает спрятанную форму. */
.btn-add {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    list-style: none;
    box-shadow: var(--shadow);
    transition: background .15s, transform .15s;
}
.btn-add::-webkit-details-marker { display: none; }
.btn-add:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
/* Открытая форма — «+» превращается в «×». */
details[open] > .btn-add { background: var(--muted); transform: rotate(45deg); }
/* Заголовок формы внутри раскрытой карточки. */
.toggler-form { margin-bottom: 16px; }
.toggler-form > .card { margin-top: 0; }
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: 20px; }
.footer-inner { max-width: 860px; margin: 0 auto; padding: 16px 14px calc(var(--nav-h, 96px) + 36px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 8px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.legal h2 { margin-top: 6px; }
.legal p, .legal li { font-size: 15px; color: #33404e; }
.hero { text-align: center; padding: 26px 6px 8px; }
.hero h1 { font-size: 24px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0 0 16px; }

.landing-hero {
    text-align: center;
    padding: 38px 18px 30px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(135deg, #ecfdf3 0%, #ffffff 55%, #eef4ff 100%);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.landing-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 12px;
    background: rgba(18, 183, 106, .12);
    color: #087443;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 12px;
}
.landing-hero h1 {
    margin: 0 auto 12px;
    max-width: 720px;
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.08;
    letter-spacing: -0.03em;
}
.landing-hero p {
    max-width: 660px;
    margin: 0 auto 22px;
    color: var(--muted);
    font-size: 17px;
}
.landing-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.landing-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.landing-card span {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #f2f6f8;
    font-size: 21px;
    margin-bottom: 8px;
}
.landing-card h2 {
    margin: 0 0 6px;
    font-size: 17px;
}
.landing-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14.5px;
}
.landing-strip {
    text-align: center;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px 18px;
    box-shadow: var(--shadow);
}
.landing-strip h2 { margin-top: 0; }
.landing-strip p { color: var(--muted); max-width: 680px; margin: 0 auto 16px; }
.stat { display: block; color: inherit; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; border-color: #cfe3d9; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; }
.events-card,
.reminder-card,
.quick-actions-card { margin-top: 18px; }
.quick-actions-card h2 { margin-top: 0; }

/* ---------- Широкие экраны ---------- */
@media (min-width: 720px) {
    .bottomnav {
        left: 50%; right: auto; transform: translateX(-50%);
        bottom: 18px;
        width: min(480px, 92vw);
        border-radius: 999px;
        border: 1px solid var(--line);
        padding-bottom: 0;
        box-shadow: 0 8px 30px rgba(16,24,40,.14);
    }
    .bottomnav-link { padding: 10px 4px 12px; }
    .page { padding-top: 22px; padding-bottom: 130px; }

    /*
     * Десктоп: чат перестаёт быть «на весь экран» и живёт в колонке той же
     * ширины, что и остальные страницы (860px) — карточкой по центру.
     */
    body.has-chat-app { overflow: auto; }
    .chat-app {
        /* relative, а не static: кнопка «вниз» позиционируется от карточки чата,
           иначе на десктопе она улетает в угол окна. */
        position: relative;
        inset: auto;
        height: auto;
        min-height: 0;
        max-width: 860px;
        margin: 22px auto 130px;
        border: 1px solid var(--line);
        border-radius: 16px;
        overflow: hidden;
        box-shadow: var(--shadow);
        background: var(--card);
    }
    .chat-topbar {
        padding: 12px 16px;
        border-radius: 16px 16px 0 0;
        box-shadow: none;
    }
    /*
     * Лента подстраивается под содержимое, но не выше ~60% экрана —
     * дальше скроллится она сама, а не вся страница.
     */
    .chat-scroll {
        height: auto;
        min-height: 220px;
        max-height: calc(100vh - 330px);
        padding: 16px;
    }
    /*
     * Короткую переписку прижимаем к полю ввода распоркой, а НЕ через
     * justify-content: flex-end — тот в скроллящемся flex-контейнере
     * обрезает верхние сообщения без возможности до них домотать.
     */
    .chat-scroll::before {
        content: '';
        margin-top: auto;
    }
    .chat-composer {
        padding: 12px 16px;
        padding-bottom: 12px;   /* плавающее меню больше не перекрывает поле */
        border-radius: 0 0 16px 16px;
    }
    /* Поле ввода шире: растягиваем строку на всю карточку. */
    .composer-row { gap: 10px; width: 100%; }
    .composer-row .chat-message-input {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
        padding: 12px 14px;
        font-size: 15.5px;
    }
    .composer-attach { width: 44px; height: 44px; }
    .composer-row .btn { flex: none; padding: 12px 22px; }
    /* Сообщения на широком экране не растягиваем во всю ширину. */
    .msg { max-width: 74%; }
    /* Логотип в шапке на широких экранах — умеренного размера. */
    .topbar { padding: 10px 20px; }
    .logo { width: 56px; height: 56px; max-width: 56px; max-height: 56px; }
    .brand { font-size: 20px; }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .footer-inner { padding-bottom: 120px; flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ---------- Раздел модерации ---------- */
.mod-card { padding: 14px; }
.mod-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 13px;
}
.mod-author { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-reporters { margin: 0 0 9px; font-size: 14px; }
.mod-reporters ul { margin: 5px 0 0; padding-left: 22px; }
.mod-reporters li { margin: 3px 0; }
.mod-report-links { margin: 0 0 10px; }
.mod-delete-user-form { margin-top: 8px; }
.mod-support-row-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.mod-support-row-wrap .chat-row { width: 100%; }
.mod-support-delete { margin: 0; padding: 0 8px 2px; }
.mod-text {
    background: #f6f8fa;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    word-break: break-word;
}
.mod-photo {
    display: block;
    max-width: 160px;
    max-height: 160px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: zoom-in;
}
.mod-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }


/* ---------- Тип объекта и отключённые оповещения ---------- */
.choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px 0 12px;
}
.choice-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}
.choice-pill input { width: auto; margin: 0; }
.choice-pill:has(input:checked) {
    border-color: var(--brand);
    background: #e9f8f0;
    color: var(--brand-dark);
}
.nested-options {
    margin: 6px 0 12px 22px;
    padding-left: 12px;
    border-left: 3px solid #e3e8ee;
}
.item-muted-bell {
    flex: none;
    margin-left: 4px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
}
.object-filter-tabs { margin-top: -2px; }

/* Действия заявки на закупку: интервалы сохраняются и при переносе кнопок. */
.purchase-action-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.purchase-action-buttons .purchase-action-form {
    display: flex;
    margin: 0;
}

/* Заявки на закупку материалов. */
.purchase-items-dynamic {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.purchase-items-view {
    margin: 0 0 14px;
    padding-left: 22px;
    line-height: 1.65;
}
.purchase-items-view li {
    padding: 3px 0;
}
.list-item.ticket-row-closed,
.purchase-closed {
    background: #f1f3f5;
    border-color: #dce2e8;
    color: #66727d;
    box-shadow: none;
}
.list-item.ticket-row-closed:hover {
    background: #eceff2;
    border-color: #ccd5dd;
}

/* Иконка отключённых уведомлений: не emoji, а серый зачёркнутый колокольчик. */
.item-muted-bell svg {
    width: 20px;
    height: 20px;
    display: block;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* В списках заявок тип заявки показывается значком над статусом. */
.ticket-row-side {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 78px;
}
.ticket-type-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef4f8;
    color: #516171;
    font-size: 16px;
    line-height: 1;
}
.ticket-type-purchase { background: #eef7ef; }
.ticket-type-to { background: #eef6ff; }
.ticket-type-repair { background: #fff5e8; }
.ticket-type-install { background: #f2efff; }

/* ---------- Новые события на главной ---------- */
.events-card h2 { margin-top: 0; }
.event-item .event-icon {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #eef5f8;
    color: #4a545f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* ---------- Брендинг компании ---------- */
.company-logo-preview {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #f6f8fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
    flex: 0 0 72px;
}
.company-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.client-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.client-brand img {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    object-fit: contain;
    padding: 4px;
}

/* ---------- Вкладки страницы чатов: округлые «папки», активная едина со страницей ---------- */
.chat-tabs,
.folder-tabs {
    position: relative;
    align-items: flex-end;
    gap: 3px;
    overflow: visible;           /* строка больше не является горизонтальным скролл-контейнером */
    width: 100%;
    max-width: 100%;
    margin: 0 0 12px;
    padding: 5px 10px 0;
    border-bottom: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chat-tabs::-webkit-scrollbar,
.folder-tabs::-webkit-scrollbar { display: none; }
.chat-tabs .tab,
.folder-tabs .tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    min-height: 34px;
    padding: 7px 11px 6px;
    margin: 0;
    border: 1px solid #c9d2db;
    border-bottom-color: #c9d2db;
    border-radius: 16px 16px 0 0;
    background: #d7dfe6;          /* неактивные чуть темнее */
    color: #566371;
    clip-path: none;
    box-shadow: inset 0 -8px 12px rgba(31,41,55,.06);
    z-index: 1;
    overflow: visible;
    font-size: 13.5px;
    line-height: 1.15;
    transition: transform .15s, background .15s, color .15s, box-shadow .15s, border-color .15s;
}
/* Небольшие боковые «крылья» дают вкладке мягкую трапециевидную форму без острых углов. */
.chat-tabs .tab::before,
.chat-tabs .tab::after,
.folder-tabs .tab::before,
.folder-tabs .tab::after {
    content: '';
    position: absolute;
    top: 0;                      /* верхняя линия совпадает с центральной частью вкладки */
    bottom: -1px;
    width: 12px;
    background: inherit;
    border: 1px solid #c9d2db;
    border-bottom-color: inherit;
    pointer-events: none;
    z-index: -1;
}
.chat-tabs .tab::before,
.folder-tabs .tab::before {
    left: -5px;
    border-right: none;
    border-radius: 14px 0 0 0;
    transform: skewX(-12deg);
    transform-origin: bottom right;
}
.chat-tabs .tab::after,
.folder-tabs .tab::after {
    right: -5px;
    border-left: none;
    border-radius: 0 14px 0 0;
    transform: skewX(12deg);
    transform-origin: bottom left;
}
.chat-tabs .tab:hover,
.folder-tabs .tab:hover {
    background: #e2e8ee;
    color: var(--ink);
    text-decoration: none;
}
.chat-tabs .tab.active,
.folder-tabs .tab.active {
    background: var(--bg);       /* один цвет со страницей */
    color: var(--brand-dark);
    border-color: #c9d2db;
    border-bottom-color: var(--bg); /* без разделительной полосы снизу */
    box-shadow: 0 -5px 16px rgba(31,41,55,.10);
    transform: translateY(1px);
    z-index: 5;
}
.chat-tabs .tab.active::before,
.chat-tabs .tab.active::after,
.folder-tabs .tab.active::before,
.folder-tabs .tab.active::after {
    border-color: #c9d2db;
    border-bottom-color: var(--bg);
}
.tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239,68,68,.14);
    flex: none;
}
.chat-tabs .tab.active .tab-dot,
.folder-tabs .tab.active .tab-dot {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239,68,68,.18);
}

.folder-tabs {
    flex-wrap: wrap;
    align-items: flex-end;
}
.folder-tabs .tab {
    flex: 1 1 auto;
    min-width: 92px;
}
.ticket-status-tabs .tab {
    min-width: 104px;
}
.brand-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-row-company {
    border-color: #d7e7ef;
    background: linear-gradient(135deg, #fff 0%, #f3f8fb 100%);
}
.chat-row-company .chat-row-title::after {
    content: 'Компания';
    display: inline-flex;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #e7f1f6;
    color: #587489;
    font-size: 11px;
    font-weight: 800;
    vertical-align: 1px;
}

/* ---------- Удалённые сообщения, личные заметки и напоминания ---------- */
.msg.deleted .msg-bubble {
    opacity: .78;
}
.msg-deleted {
    color: var(--muted);
    font-style: italic;
}
.personal-note-card textarea {
    min-height: 110px;
}
.reminder-card .reminder-form {
    margin-bottom: 0;
}
.reminder-item .main {
    min-width: 0;
}
.reminder-due-card {
    border-color: #fed7aa;
    background: linear-gradient(135deg, #fff 0%, #fff7ed 100%);
}
.reminder-popup {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, .36);
    animation: reminderFadeIn .18s ease-out;
}
.reminder-popup-card {
    width: min(420px, 100%);
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .35);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    padding: 20px;
}
.reminder-popup-card h2 {
    margin-top: 0;
}
.reminder-popup-text {
    font-size: 17px;
    line-height: 1.45;
    margin: 8px 0;
    word-break: break-word;
}
@keyframes reminderFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---------- Подтверждение контактов и пригласительные ссылки ---------- */
.status-ok {
    color: #15803d;
    font-weight: 700;
}
.verify-needed-card {
    border-color: #fed7aa;
    background: linear-gradient(135deg, #fff 0%, #fff7ed 100%);
}
.verify-call-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
}
.verify-call-number {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: .04em;
    margin: 6px 0;
}
.verify-call-number a {
    color: var(--brand-dark);
    text-decoration: none;
}

/* ---------- Правки заметок объекта, вкладок заявок и напоминаний ---------- */
.personal-note-filled .personal-note-text {
    white-space: pre-wrap;
    line-height: 1.5;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
    margin-bottom: 10px;
}
.personal-note-edit,
.personal-note-empty {
    margin-top: 10px;
}
.personal-note-empty > .card {
    margin-top: 10px;
}
.ticket-page-head {
    justify-content: flex-end;
    min-height: 0;
    margin-bottom: 8px;
}
.ticket-status-scroll {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 12px;
}
.ticket-status-scroll .ticket-status-tabs {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    width: auto;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-left: 12px;
    padding-right: 12px;
    margin-bottom: 0;
}
.ticket-status-scroll .ticket-status-tabs::-webkit-scrollbar {
    display: none;
}
.ticket-status-scroll .ticket-status-tabs .tab {
    flex: 0 0 auto;
    min-width: 0;
    width: auto;
    padding-left: 14px;
    padding-right: 14px;
}
.tabs-scroll-hints::before,
.tabs-scroll-hints::after {
    content: '';
    position: absolute;
    top: 50%;
    z-index: 12;
    width: 0;
    height: 0;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
}
.tabs-scroll-hints::before {
    left: 2px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 7px solid rgba(31, 41, 55, .55);
}
.tabs-scroll-hints::after {
    right: 2px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid rgba(31, 41, 55, .55);
}
.tabs-scroll-hints.can-scroll-left::before,
.tabs-scroll-hints.can-scroll-right::after {
    opacity: 1;
}
.quick-actions-card .quick-reminder-action,
.quick-reminder-action[open] {
    flex-basis: 100%;
}
.quick-reminder-action:not([open]) {
    flex-basis: auto;
}
.quick-reminder-action summary {
    width: fit-content;
}
.quick-reminder-form {
    max-width: 520px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
}
.reminder-card .list {
    margin: 0;
}
.reminder-item-due {
    border-color: #fed7aa;
    background: #fff7ed;
}
.reminder-popup-actions {
    align-items: flex-start;
    justify-content: center;
}
.reminder-snooze {
    margin: 0;
}
.reminder-snooze-options {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    justify-content: center;
}

/* ---------- Приглашения: кнопки не должны вылезать в мобильной строке ---------- */
.invite-list-item {
    align-items: flex-start;
}
.invite-actions,
.flash-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}
.invite-actions form.inline,
.flash-actions form.inline {
    display: inline-flex;
}
.flash-actions {
    margin-left: 8px;
    vertical-align: middle;
}
@media (max-width: 560px) {
    /* В строке участника объектные данные сверху, действия — отдельными строками ниже. */
    .object-staff-row {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        align-items: start;
        column-gap: 10px;
        row-gap: 10px;
    }
    .object-staff-row > .staff-cell { grid-column: 1; grid-row: 1; }
    .object-staff-row > .main { grid-column: 2; grid-row: 1; min-width: 0; }
    .object-staff-row > form.inline,
    .object-staff-row > details.object-member-permissions {
        grid-column: 1 / -1;
        justify-self: start;
        margin: 0;
    }
    .invite-list-item {
        flex-wrap: wrap;
    }
    .object-archive-item > span:first-child { display: none; }
    .object-archive-item > .main { flex: 1 1 100%; }
    .object-archive-item .invite-actions { padding-left: 0; }
    .invite-list-item > .main {
        flex: 1 1 calc(100% - 34px);
    }
    .invite-actions {
        flex: 1 0 100%;
        justify-content: flex-start;
        padding-left: 32px;
        margin-top: 2px;
    }
    .invite-actions .btn,
    .flash-actions .btn {
        min-height: 34px;
    }
    .flash-actions {
        display: flex;
        margin: 8px 0 0;
        justify-content: flex-start;
    }
}

/* ---------- Настройки: сворачиваемые пункты меню ---------- */
.settings-section {
    margin-bottom: 10px;
}
.settings-section > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--shadow);
    font-weight: 800;
}
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
    transition: transform .15s;
    flex: none;
}
.settings-section[open] > summary::after {
    transform: rotate(180deg);
}
.settings-section > .card {
    margin-top: 8px;
}
.settings-section > .card > h2:first-child {
    display: none;
}
.settings-section > form,
.settings-section > details {
    margin-top: 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
}
.settings-section-danger > summary { color: var(--danger); }

@media (max-width: 480px) {
    .company-context-switcher { padding: 8px 12px; }
    .company-context-switcher form { align-items: stretch; gap: 7px; flex-wrap: wrap; }
    .company-context-switcher label { width: 100%; }
    .company-context-switcher select { max-width: none; width: 100%; flex-basis: 100%; }
    .company-context-switcher p { font-size: 11.5px; }
}

/* ---------- Объект: информация для команды ---------- */
.object-info-text {
    line-height: 1.55;
    overflow-wrap: anywhere;
}

/* ---------- Быстрые действия: равная сетка вместо разъезжающихся flex-кнопок ---------- */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
}
.quick-actions-grid > .btn,
.quick-actions-grid > .quick-reminder-action {
    width: 100%;
    min-width: 0;
    margin: 0;
}
.quick-actions-grid > .btn {
    box-sizing: border-box;
    min-height: 44px;
    padding-inline: 8px;
    white-space: normal;
    text-align: center;
}
.quick-actions-grid .quick-reminder-action > summary {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    white-space: normal;
    text-align: center;
}
.quick-actions-grid > .quick-reminder-action[open] {
    grid-column: 1 / -1;
}
.quick-actions-grid > .quick-reminder-action[open] .quick-reminder-form {
    width: 100%;
    max-width: none;
}
.quick-actions-grid > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 8px) / 2);
}
@media (min-width: 560px) {
    .quick-actions-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .quick-actions-grid > :last-child:nth-child(odd) {
        grid-column: auto;
        justify-self: stretch;
        width: 100%;
    }
}

/* ---------- Администраторская статистика ---------- */
.stats-metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.stats-metric-grid .stat {
    min-width: 0;
    padding: 12px 8px;
}
.stats-metric-grid .stat b {
    font-size: clamp(19px, 5vw, 25px);
    overflow-wrap: anywhere;
}
.stats-metric-grid .stat span {
    display: block;
    line-height: 1.35;
}
.stats-number {
    flex: none;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
@media (min-width: 720px) {
    .stats-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
    .stats-metric-grid { grid-template-columns: 1fr; }
}

/* ---------- Правила глобальных чатов ---------- */
.chat-rules-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 14px;
    padding: 12px 14px;
    background: linear-gradient(120deg, var(--brand-soft), var(--card) 78%);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.chat-rules-notice p {
    flex: 1;
    margin: 0;
    color: var(--ink);
    font-size: 14px;
}
.chat-rules-notice p a { color: var(--brand-dark); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.chat-rules-ack-form { flex: none; margin: 0; }
.chat-rules-ack-form .btn { min-width: 58px; }

.chat-rules-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 18px;
    padding: 13px 15px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.chat-rules-card:hover {
    color: var(--ink);
    text-decoration: none;
    border-color: var(--brand);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16,24,40,.09);
}
.chat-rules-card-mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    color: var(--brand-dark);
    background: var(--brand-soft);
    font-size: 18px;
    font-weight: 800;
}
.chat-rules-card-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.chat-rules-card-copy strong { color: var(--ink); font-size: 14px; }
.chat-rules-card-copy > span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.chat-rules-card-arrow { flex: none; color: var(--brand-dark); font-size: 20px; font-weight: 700; }

.chat-rules-page .chat-rules-intro { margin: 0 0 12px; color: var(--ink); font-size: 16px; font-weight: 600; }
.chat-rules-page ol { margin: 0; padding-left: 23px; }
.chat-rules-page li { margin: 9px 0; padding-left: 3px; color: var(--ink); font-size: 15px; }
.chat-rules-page li::marker { color: var(--brand-dark); font-weight: 800; }
.chat-rules-page-head { align-items: center; }
.chat-rules-card:focus-visible,
.chat-rules-notice a:focus-visible,
.chat-rules-ack-form .btn:focus-visible {
    outline: 3px solid var(--info);
    outline-offset: 3px;
}
@media (max-width: 520px) {
    .chat-rules-notice { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
    .chat-rules-notice p { flex-basis: 100%; }
    .chat-rules-ack-form { margin-left: auto; }
    .chat-rules-page-head { align-items: flex-start; }
    .chat-rules-page-head .btn { white-space: nowrap; }
    .chat-rules-card { padding: 12px; }
}

/* ---------- Учёт оборудования ---------- */
.equipment-page-head,
.equipment-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.equipment-page-head h1,
.equipment-section-heading h2 { margin: 0; }
.equipment-owner-section { margin: 18px 0 24px; }
.equipment-section-heading > div { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.equipment-role-pill,
.equipment-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}
.equipment-role-pill { background: #eef2f6; color: #526071; }
.equipment-status-stock { background: #e8f6ee; color: #176b3a; }
.equipment-status-pending { background: #fff3d8; color: #8a5a00; }
.equipment-status-issued { background: #e8efff; color: #3456a1; }
.equipment-status-return { background: #fff0e4; color: #9a4f12; }
.equipment-status-muted { background: #eef0f2; color: #5c6672; }
.equipment-pro-notice {
    margin: 10px 0 12px;
    padding: 11px 13px;
    border: 1px solid #f0d7a9;
    border-radius: 10px;
    background: #fff9ec;
    color: #75500c;
    font-size: 14px;
}
.equipment-permissions-list { display: grid; gap: 8px; margin-top: 10px; }
.permission-select-row {
    display: grid; grid-template-columns: minmax(160px, 1fr) minmax(210px, 1.2fr);
    align-items: center; gap: 12px; margin: 12px 0 0; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.permission-select-row select { margin: 0; }
.equipment-permission-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(210px, 1.2fr);
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}
.equipment-permission-row > span { display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.equipment-permission-row small { color: var(--muted); font-weight: 400; }
.equipment-list { display: grid; gap: 10px; }
.equipment-list-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 0;
}
.equipment-list-main { flex: 1; min-width: 0; }
.equipment-list-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.equipment-item-title { color: var(--ink); font-weight: 800; font-size: 16px; }
.equipment-list-meta,
.equipment-list-comment,
.equipment-subtitle { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin-top: 5px; overflow-wrap: anywhere; }
.equipment-list-comment { padding-left: 10px; border-left: 2px solid var(--line); }
.equipment-item-menu { position: relative; z-index: 1; display: flex; justify-content: flex-end; margin-top: 8px; }
.equipment-item-menu[open] { z-index: 30; }
.equipment-item-menu > summary {
    display: grid; place-items: center; width: 36px; height: 36px; margin: 0;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card);
    color: var(--ink); cursor: pointer; list-style: none; font-size: 23px; font-weight: 800; line-height: 1;
}
.equipment-item-menu > summary::-webkit-details-marker { display: none; }
.equipment-item-menu > summary:hover { background: #f5f7f9; }
.equipment-item-menu-popover {
    position: absolute; top: calc(100% + 5px); right: 0; z-index: 40;
    display: none; gap: 3px; min-width: 188px; max-width: min(280px, calc(100vw - 36px));
    padding: 6px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--card); box-shadow: 0 10px 28px rgba(16,24,40,.16);
}
.equipment-item-menu[open] > .equipment-item-menu-popover { display: grid; }
.equipment-menu-item {
    display: block; width: 100%; margin: 0; padding: 9px 10px; border: 0; border-radius: 8px;
    background: transparent; color: var(--ink); text-align: left; font: inherit; font-size: 14px;
    cursor: pointer; text-decoration: none;
}
.equipment-menu-item:hover, .equipment-menu-item:focus-visible { background: #f1f4f7; text-decoration: none; }
.equipment-menu-primary { color: var(--brand-dark); font-weight: 800; }
.equipment-menu-danger { color: #b4232b; }
.equipment-item-menu-popover form { margin: 0; }
.equipment-photo-link { display: inline-flex; flex: none; max-width: 100%; border-radius: 12px; overflow: hidden; background: #f1f3f5; }
.equipment-photo { display: block; width: 116px; height: 116px; max-width: 100%; object-fit: cover; }
.equipment-list-item > .equipment-photo-link .equipment-photo { width: 82px; height: 82px; }
.equipment-detail-card { overflow: hidden; }
.equipment-detail-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.equipment-detail-top .equipment-photo-link .equipment-photo { width: 150px; height: 150px; }
.equipment-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 17px; }
.equipment-detail-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.equipment-detail-grid b { overflow-wrap: anywhere; }
.equipment-detail-grid small { color: var(--muted); }
.equipment-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.equipment-comment,
.equipment-return-owner,
.equipment-issue-photo-block { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); }
.equipment-comment > div { overflow-wrap: anywhere; }
.equipment-private-comment { padding: 11px 13px; border: 1px solid #f0d7a9; border-radius: 10px; background: #fff9ec; }
.equipment-privacy-note { margin: 13px 0 0; font-size: 13px; }
.equipment-issue-photo-block .equipment-photo-link { margin-top: 4px; }
.equipment-action-card > h2 { margin-top: 0; }
.equipment-inline-form { margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.equipment-history-button { margin: 12px 0 22px; }
.equipment-history-list { display: grid; gap: 0; }
.equipment-history-row { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.equipment-history-row:last-child { border-bottom: 0; }
.equipment-history-mark { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--brand); }
.equipment-history-content { min-width: 0; }
.equipment-history-meta { margin-top: 3px; font-size: 12.5px; }
.equipment-history-details { margin-top: 6px; font-size: 14px; overflow-wrap: anywhere; }
.equipment-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.equipment-form-hint { margin-top: 5px; font-size: 12.5px; }
.equipment-current-photo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.equipment-remove-photo { margin: 0; }
.equipment-cost-toggle { margin-top: 13px; }
.equipment-dashboard-section { margin-top: 22px; }
.equipment-dashboard-card { padding: 16px; }
.equipment-dashboard-card > .equipment-section-heading { margin-bottom: 0; }
.equipment-home-subsection { margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--line); }
.equipment-home-subsection h3 { margin: 0 0 9px; font-size: 15px; }
.equipment-home-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 0; border-bottom: 1px solid var(--line); }
.equipment-home-row:last-child { border-bottom: 0; padding-bottom: 0; }
.equipment-home-info { display: flex; flex: 1; min-width: 180px; flex-direction: column; gap: 3px; }
.equipment-home-info .muted { font-size: 13px; }
.equipment-home-snooze { display: flex; flex-wrap: wrap; gap: 5px; }
.equipment-home-snooze form { margin: 0; }
.equipment-pending-note { color: #8a5a00; font-size: 13px; font-weight: 700; }
.equipment-inline-file { margin: 0; font-size: 12px; }
.equipment-inline-file input { display: block; width: min(250px, 100%); margin-top: 4px; font-size: 12px; }
.equipment-reminder-settings > .btn-row { align-items: center; }
.equipment-reminder-settings form { margin: 0; }
@media (max-width: 640px) {
    .permission-select-row { grid-template-columns: 1fr; gap: 4px; }
    .equipment-permission-row { grid-template-columns: 1fr; gap: 4px; }
    .equipment-list-item { gap: 10px; padding: 12px; }
    .equipment-list-item > .equipment-photo-link .equipment-photo { width: 64px; height: 64px; }
    .equipment-detail-top .equipment-photo-link .equipment-photo { width: 92px; height: 92px; }
    .equipment-form-grid { grid-template-columns: 1fr; }
    .equipment-home-row { align-items: flex-start; }
    .equipment-home-snooze { width: 100%; }
}
