:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #151a20;
    --muted: #6b7280;
    --primary: #0c6f5f;
    --danger: #b42318;
    --border: #dfe3e8;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
.wrap { width: min(960px, calc(100% - 28px)); margin: 0 auto; }
.topbar { background: #101820; color: #fff; }
.topbar-inner {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand { color: #fff; font-weight: 800; font-size: 20px; }
nav { display: flex; gap: 16px; flex-wrap: wrap; }
nav a { color: #fff; }
main.wrap { padding: 22px 0 42px; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 4px 18px rgba(0,0,0,.04);
}
.auth-card { max-width: 520px; margin: 24px auto; }
h1,h2 { margin-top: 0; }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid #cfd5dc;
    border-radius: 12px;
    padding: 13px 14px;
    font: inherit;
    background: #fff;
}
textarea { resize: vertical; }
.btn {
    display: inline-block;
    border: 0;
    border-radius: 12px;
    padding: 13px 17px;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
}
.primary { background: var(--primary); color: #fff; }
.secondary { background: #e7ebef; color: #111; }
.danger { background: var(--danger); color: #fff; }
.alert { padding: 13px 15px; border-radius: 12px; margin-bottom: 16px; }
.alert.error { background: #ffe5e5; color: #8a1111; }
.alert.success { background: #e4f7e8; color: #176128; }
.muted { color: var(--muted); }
.page-head { margin-bottom: 18px; }
.loader-card { position: relative; }
.state-number { font-size: 25px; font-weight: 900; margin: 8px 0; }
.badge {
    display: inline-block;
    padding: 7px 11px;
    border-radius: 999px;
    background: #e8eef7;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}
.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.big-action { color: var(--text); min-height: 145px; display: flex; flex-direction: column; justify-content: center; }
.big-action span { font-size: 22px; font-weight: 900; }
.big-action small { margin-top: 8px; color: var(--muted); }
.danger-action { border-left: 5px solid var(--danger); }
.list { display: grid; gap: 12px; }
.list-item { border-top: 1px solid var(--border); padding-top: 14px; }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item small { display: block; margin-top: 8px; color: var(--muted); }
.note { margin-top: 10px; padding: 10px; background: #f3f5f7; border-radius: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.footer { color: var(--muted); padding: 0 0 30px; font-size: 13px; }

@media (max-width: 640px) {
    .actions-grid { grid-template-columns: 1fr; }
    .topbar-inner { align-items: flex-start; padding: 14px 0; flex-direction: column; }
    nav { gap: 12px; }
    .card { padding: 16px; border-radius: 14px; }
    .state-number { font-size: 22px; }
}


/* БРУ-АТЦ mobile additions */
body {
    min-height: 100vh;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand {
    letter-spacing: .3px;
}
.fault-photo {
    display: block;
    width: min(100%, 420px);
    max-height: 320px;
    object-fit: cover;
    border-radius: 12px;
    margin-top: 12px;
    border: 1px solid var(--border);
}
@media (max-width: 640px) {
    main.wrap { padding-top: 14px; }
    .topbar-inner { min-height: 52px; }
    .brand { font-size: 18px; }
    .big-action { min-height: 120px; }
    .big-action span { font-size: 20px; }
    input, select, textarea { font-size: 16px; }
    .btn { width: 100%; min-height: 48px; }
}

.status-tracking {
    margin: 12px 0 16px;
    padding: 12px 14px;
    background: #f4f7f7;
    border: 1px solid var(--border);
    border-radius: 12px;
    display: grid;
    gap: 7px;
    font-size: 14px;
}
.status-tracking.compact {
    margin-top: 10px;
    margin-bottom: 0;
}

.delete-form {
    margin-top: 12px;
}
.delete-btn {
    background: #fff;
    color: #9f1d1d;
    border: 1px solid #d9aaaa;
}
.delete-btn:hover {
    background: #fff1f1;
}

.notification-unread {
    background: #fff8db;
    border-radius: 10px;
    padding: 12px;
}

.chat-card {
    padding-bottom: 14px;
}
.chat-messages {
    display: grid;
    gap: 10px;
    max-height: 62vh;
    overflow-y: auto;
    padding: 4px 2px 14px;
}
.chat-message {
    max-width: 82%;
    background: #f1f3f5;
    border-radius: 14px;
    padding: 10px 12px;
    justify-self: start;
}
.chat-message.mine {
    background: #dff4ee;
    justify-self: end;
}
.chat-meta {
    font-size: 13px;
    margin-bottom: 5px;
}
.chat-message small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}
.chat-form {
    display: grid;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}
.info-box {
    background: #eef5ff;
    border-radius: 12px;
    padding: 12px 14px;
}

/* Улучшенный чат БРУ-АТЦ */
.chat-card {
    overflow: hidden;
}
.chat-messages {
    gap: 12px;
    padding: 10px 4px 18px;
}
.chat-message {
    position: relative;
    width: fit-content;
    max-width: min(82%, 620px);
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 3px 12px rgba(0,0,0,.05);
    border-radius: 16px 16px 16px 5px;
    padding: 11px 13px;
}
.chat-message.mine {
    background: #e8f6f2;
    border-color: #c6e5dd;
    border-radius: 16px 16px 5px 16px;
}
.chat-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.shift-pill, .role-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 11px;
    background: #eef1f4;
    color: #505862;
}
.role-pill {
    background: #e4f2ff;
    color: #18558a;
}
.admin-pill {
    background: #f3e8ff;
    color: #6c2ea4;
}
.chat-text {
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.chat-bottom {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 7px;
}
.mod-menu {
    position: relative;
}
.mod-menu summary {
    list-style: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 16px;
    color: var(--muted);
    padding: 0 4px;
}
.mod-menu summary::-webkit-details-marker {
    display: none;
}
.mod-panel {
    position: absolute;
    right: 0;
    bottom: 24px;
    width: min(300px, 82vw);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 35px rgba(0,0,0,.18);
    padding: 10px;
    z-index: 20;
}
.mod-form {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}
.mod-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px;
}
.mod-row input, .mod-form input {
    padding: 9px 10px;
    border-radius: 9px;
}
.mod-link {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 9px 10px;
    border-radius: 9px;
    cursor: pointer;
    font: inherit;
}
.mod-link:hover {
    background: #f4f6f8;
}
.danger-text {
    color: #a61b1b;
}
.deleted-message {
    color: var(--muted);
    font-style: italic;
}
.deleted-message small {
    margin-top: 4px;
}
@media (max-width:640px) {
    .chat-message { max-width: 90%; }
    .chat-messages { max-height: 64vh; }
}


/* ===== БРУ-АТЦ: вход и регистрация ===== */
.auth-screen {
    min-height: 100vh;
    margin: 0;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(5,8,10,.34), rgba(5,8,10,.70)),
        url('/assets/img/auth-background.png') center center / cover no-repeat fixed;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 560px);
    align-items: center;
    gap: 44px;
    padding: 42px clamp(24px, 6vw, 88px);
    background: linear-gradient(90deg, rgba(0,0,0,.12), rgba(0,0,0,.42));
}

.auth-brand-panel {
    max-width: 660px;
    align-self: center;
    text-align: center;
    filter: drop-shadow(0 12px 28px rgba(0,0,0,.5));
}

.auth-logo {
    display: block;
    width: min(520px, 88%);
    margin: 0 auto 8px;
    object-fit: contain;
}

.auth-company,
.auth-mine {
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 12px #000;
}

.auth-company {
    font-size: clamp(18px, 2.1vw, 30px);
}

.auth-mine {
    font-size: clamp(16px, 1.7vw, 24px);
    margin-top: 4px;
}

.auth-tagline {
    width: fit-content;
    max-width: 100%;
    margin: 30px auto 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,.28);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 3px;
    color: rgba(255,255,255,.85);
    text-shadow: 0 2px 10px #000;
}

.auth-form-panel {
    display: flex;
    justify-content: center;
    width: 100%;
}

.auth-form-wrap {
    width: 100%;
    max-width: 520px;
    padding: 34px 38px 30px;
    background:
        linear-gradient(180deg, rgba(34,34,34,.97), rgba(11,13,15,.97));
    border: 1px solid rgba(255,137,24,.82);
    border-radius: 26px;
    box-shadow:
        0 24px 70px rgba(0,0,0,.55),
        inset 0 0 0 1px rgba(255,255,255,.025);
    position: relative;
    overflow: hidden;
}

.auth-form-wrap::before,
.auth-form-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #ff8717 20%, #ff8717 80%, transparent);
}

.auth-form-wrap::before { top: 0; }
.auth-form-wrap::after { bottom: 0; }

.auth-form-icon {
    text-align: center;
    font-size: 34px;
    margin-bottom: 6px;
}

.auth-form-wrap h1 {
    margin: 0;
    text-align: center;
    text-transform: uppercase;
    font-size: clamp(28px, 4vw, 46px);
    letter-spacing: .8px;
}

.auth-subtitle {
    margin: 10px 0 24px;
    text-align: center;
    color: #c9c9c9;
    font-weight: 600;
    line-height: 1.4;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-field {
    display: grid;
    grid-template-columns: 44px 1fr;
    align-items: center;
    min-height: 54px;
    background: rgba(4,6,8,.72);
    border: 1px solid #4a4f55;
    border-radius: 12px;
    overflow: hidden;
    transition: .2s ease;
}

.auth-field:focus-within {
    border-color: #ff8518;
    box-shadow: 0 0 0 3px rgba(255,133,24,.12);
}

.auth-field-icon {
    display: grid;
    place-items: center;
    color: #ff8518;
    font-weight: 900;
    font-size: 18px;
}

.auth-field input {
    height: 54px;
    padding: 0 14px 0 0;
    border: 0;
    outline: 0;
    border-radius: 0;
    color: #fff;
    background: transparent;
    font-size: 16px;
}

.auth-field input::placeholder {
    color: #8d9298;
}

.auth-submit {
    min-height: 58px;
    margin-top: 8px;
    border: 0;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(180deg, #ff941f, #ff7911);
    box-shadow: 0 8px 24px rgba(255,123,17,.25);
    text-transform: uppercase;
    font-weight: 900;
    font-size: 18px;
    cursor: pointer;
}

.auth-submit span {
    font-size: 28px;
    vertical-align: -2px;
    margin-left: 8px;
}

.auth-bottom-text {
    margin: 18px 0 0;
    text-align: center;
    color: #bbb;
}

.auth-bottom-text a {
    color: #ff941f;
    font-weight: 800;
}

.auth-form-wrap .alert {
    border: 1px solid rgba(255,255,255,.09);
}

.compact-auth {
    max-width: 480px;
}

@media (max-width: 900px) {
    .auth-screen {
        background-position: 42% center;
    }

    .auth-shell {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 24px 18px 34px;
        align-content: start;
    }

    .auth-brand-panel {
        padding-top: 4px;
    }

    .auth-logo {
        width: min(330px, 82vw);
        margin-bottom: 0;
    }

    .auth-company {
        font-size: 16px;
    }

    .auth-mine {
        font-size: 14px;
    }

    .auth-tagline {
        display: none;
    }

    .auth-form-wrap {
        padding: 25px 18px 22px;
        border-radius: 20px;
        max-width: 560px;
    }

    .auth-form-wrap h1 {
        font-size: 30px;
    }

    .auth-subtitle {
        font-size: 14px;
        margin-bottom: 18px;
    }
}

@media (max-width: 520px) {
    .auth-shell {
        padding: 14px 12px 24px;
    }

    .auth-brand-panel {
        margin-top: 2px;
    }

    .auth-logo {
        width: 260px;
    }

    .auth-company,
    .auth-mine {
        display: none;
    }

    .auth-form-wrap {
        padding: 20px 14px;
        border-radius: 16px;
    }

    .auth-field {
        grid-template-columns: 40px 1fr;
        min-height: 50px;
    }

    .auth-field input {
        height: 50px;
        font-size: 16px;
    }

    .auth-submit {
        min-height: 54px;
        font-size: 16px;
    }
}

.moderator-pill {
    background: #fff0d8;
    color: #9a5200;
}
.staff-role-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.staff-role-head h2 {
    margin-bottom: 4px;
}
.staff-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.check-row {
    display: flex;
    grid-template-columns: none;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}
.check-row input {
    width: 20px;
    height: 20px;
    margin: 0;
}
@media (max-width:640px) {
    .staff-role-head {
        flex-direction: column;
    }
    .staff-badges {
        justify-content: flex-start;
    }
}


/* БРУ-АТЦ v12 workers */
.supervisor-pill {
    background: #ffe7c2;
    color: #8b4b00;
}
.worker-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0,1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.worker-stat {
    margin: 0;
    color: var(--text);
    text-align: center;
}
.worker-stat strong {
    display: block;
    font-size: 28px;
    margin-bottom: 4px;
}
.worker-stat span {
    color: var(--muted);
    font-size: 13px;
}
.workers-list {
    display: grid;
    gap: 14px;
}
.worker-card {
    margin-bottom: 0;
}
.worker-card-top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}
.worker-card-top h2 {
    margin-bottom: 5px;
}
.worker-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
    margin-top: 16px;
}
.worker-details > div {
    padding: 11px 12px;
    background: #f4f6f8;
    border-radius: 10px;
}
.worker-details span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}
.compact-filter {
    max-width: 420px;
}
@media (max-width:640px) {
    .worker-stats {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }
    .worker-card-top {
        flex-direction: column;
    }
    .worker-details {
        grid-template-columns: 1fr;
    }
}


/* БРУ-АТЦ v13 roles */
.logist-pill {
    background: #dcecff;
    color: #1f5d95;
}


/* БРУ-АТЦ v14 live chat */
.chat-live-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    font-size: 12px;
    color: #66727a;
}
.chat-live-status span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25a56a;
    box-shadow: 0 0 0 4px rgba(37,165,106,.12);
}
.chat-card {
    position: relative;
}
.chat-new-messages {
    position: absolute;
    right: 18px;
    bottom: 94px;
    z-index: 25;
    border: 0;
    border-radius: 999px;
    padding: 9px 14px;
    background: #101820;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    cursor: pointer;
}
.chat-form button:disabled {
    opacity: .65;
    cursor: wait;
}


/* БРУ-АТЦ v15 — меню модерации открывается вниз */
.mod-menu {
    position: relative;
}

.mod-menu summary {
    margin-left: auto;
    width: 28px;
    min-width: 28px;
    text-align: center;
}

.mod-menu[open] {
    min-width: min(300px, 72vw);
}

.mod-panel {
    position: static !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    width: min(300px, 72vw) !important;
    max-width: 72vw;
    margin-top: 8px;
    transform: none !important;
    box-shadow: 0 10px 28px rgba(0,0,0,.16);
}

.chat-bottom {
    align-items: flex-start;
}

@media (max-width: 640px) {
    .mod-menu[open] {
        min-width: min(270px, 78vw);
    }

    .mod-panel {
        width: min(270px, 78vw) !important;
        max-width: 78vw;
    }
}


/* БРУ-АТЦ v16 chat send + emoji */
.chat-compose-row {
    position: relative;
}

.chat-compose-row textarea {
    padding-left: 52px;
    min-height: 82px;
}

.emoji-toggle {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 12;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: #eef1f3;
    font-size: 20px;
    cursor: pointer;
}

.emoji-toggle:hover {
    background: #e1e6e9;
}

.emoji-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 40;
    width: min(330px, 88vw);
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 14px 38px rgba(0,0,0,.20);
}

.emoji-panel[hidden] {
    display: none !important;
}

.emoji-panel button {
    min-width: 0;
    height: 38px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
}

.emoji-panel button:hover {
    background: #f0f2f4;
}

.chat-ajax-error {
    margin-bottom: 10px;
}

@media (max-width: 520px) {
    .emoji-panel {
        grid-template-columns: repeat(6, 1fr);
        width: min(310px, 90vw);
    }

    .emoji-panel button {
        font-size: 21px;
    }
}


/* БРУ-АТЦ v17 labels/editing */
.profile-role {
    display: inline-flex;
    margin-top: 9px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff1d9;
    color: #8b5000;
    font-weight: 800;
    font-size: 13px;
}

.loader-status-working {
    background: #e6f7ec;
    color: #196a38;
}

.loader-status-maintenance {
    background: #fff3d5;
    color: #8a5a00;
}

.loader-status-broken {
    background: #ffe4e1;
    color: #9b1c1c;
}

.fault-owner-actions {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.fault-owner-actions details {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafbfc;
    overflow: hidden;
}

.fault-owner-actions summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 800;
}

.fault-edit-form {
    padding: 0 14px 14px;
}

.chat-message .mod-panel {
    overflow: visible;
}

@media (max-width: 640px) {
    .profile-role {
        font-size: 12px;
    }
}


/* БРУ-АТЦ v18 social chat */
.social-chat-card {
    width: min(100%, 820px);
    margin-left: auto;
    margin-right: auto;
    padding: 0;
    overflow: visible;
    border-radius: 18px;
}

.social-chat-card .chat-messages {
    max-height: 64vh;
    min-height: 320px;
    padding: 18px 16px;
    background:
        radial-gradient(circle at 20% 20%, rgba(12,111,95,.035), transparent 35%),
        #f7f8fa;
    border-radius: 18px 18px 0 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.social-message {
    display: flex;
    align-items: flex-end;
    gap: 9px;
    width: 100%;
    margin: 0 0 12px;
}

.social-message.mine {
    justify-content: flex-end;
}

.social-avatar {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #dfe5e9;
    color: #37434b;
    font-size: 12px;
    font-weight: 900;
    user-select: none;
}

.mine-avatar {
    background: #0c6f5f;
    color: #fff;
}

.social-message-body {
    min-width: 0;
    max-width: min(72%, 560px);
}

.social-message.mine .social-message-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.social-message-author {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 0 0 4px 5px;
    color: #4f5961;
    font-size: 11px;
}

.social-message-author strong {
    color: #263038;
    font-size: 12px;
}

.social-meta-pill {
    padding: 2px 6px;
    border-radius: 999px;
    background: #e8ecef;
    color: #68727a;
    font-size: 9px;
    font-weight: 700;
}

.social-meta-pill.role {
    background: #e5f1ef;
    color: #397066;
}

.social-meta-pill.moderator {
    background: #fff0d7;
    color: #8d5604;
}

.social-bubble {
    position: relative;
    display: inline-block;
    max-width: 100%;
    min-width: 86px;
    padding: 9px 11px 6px;
    border-radius: 16px 16px 16px 5px;
    background: #fff;
    border: 1px solid #e1e5e8;
    box-shadow: 0 2px 6px rgba(0,0,0,.045);
}

.social-message.mine .social-bubble {
    background: #dff4ee;
    border-color: #c4e6dc;
    border-radius: 16px 16px 5px 16px;
}

.social-bubble .chat-text {
    color: #171b1f;
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    white-space: normal;
}

.social-message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
    min-height: 16px;
}

.social-message-footer small {
    color: #8a949b;
    font-size: 9px;
    white-space: nowrap;
}

.social-message-menu {
    position: relative;
}

.social-message-menu summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    color: #7d878e;
    font-size: 12px;
    line-height: 1;
    letter-spacing: 1px;
    padding: 2px 1px;
}

.social-message-menu summary::-webkit-details-marker {
    display: none;
}

.social-message-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    z-index: 100;
    width: 210px;
    padding: 6px;
    border: 1px solid #dde2e6;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(0,0,0,.16);
}

.social-message.mine .social-message-menu-panel {
    right: 0;
}

.social-menu-item {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 8px;
    padding: 9px 10px;
    background: transparent;
    color: #283139;
    text-align: left;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.social-menu-item:hover {
    background: #f3f5f6;
}

.social-menu-item.danger {
    color: #b42318;
}

.social-mod-form {
    display: grid;
    gap: 5px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid #eceff1;
}

.social-mod-form input {
    padding: 8px 9px;
    font-size: 12px;
    border-radius: 8px;
}

.social-mute-row {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 5px;
}

.inline-edit-box[hidden] {
    display: none !important;
}

.inline-edit-text {
    width: min(420px, 60vw);
    min-width: 210px;
    min-height: 82px;
    padding: 9px 10px;
    border: 1px solid #b9c5ca;
    border-radius: 10px;
    background: #fff;
    color: #171b1f;
    font: inherit;
    font-size: 14px;
    resize: vertical;
}

.inline-edit-actions {
    display: flex;
    gap: 7px;
    justify-content: flex-end;
    margin-top: 7px;
}

.mini-btn {
    border: 0;
    border-radius: 8px;
    padding: 7px 10px;
    background: #0c6f5f;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.mini-btn.secondary {
    background: #e6eaed;
    color: #333b40;
}

.social-chat-card .chat-form {
    position: relative;
    padding: 12px;
    border-top: 1px solid #e2e6e9;
    background: #fff;
    border-radius: 0 0 18px 18px;
}

.social-chat-card .chat-compose-row textarea {
    min-height: 58px;
    max-height: 120px;
    border-radius: 15px;
    background: #f7f8fa;
}

.chat-empty-state {
    min-height: 250px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    text-align: center;
    color: #7d878e;
}

.chat-empty-icon {
    font-size: 36px;
}

.chat-empty-state strong {
    color: #3c464d;
}

.chat-toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 9999;
    transform: translate(-50%, 16px);
    opacity: 0;
    pointer-events: none;
    padding: 10px 14px;
    border-radius: 999px;
    background: #172026;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 8px 28px rgba(0,0,0,.2);
    transition: .18s ease;
}

.chat-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.chat-toast.error {
    background: #a61b1b;
}

@media (max-width: 640px) {
    .social-chat-card {
        width: 100%;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .social-chat-card .chat-messages {
        min-height: 54vh;
        max-height: 62vh;
        padding: 14px 10px;
        border-radius: 0;
    }

    .social-message {
        gap: 6px;
        margin-bottom: 10px;
    }

    .social-avatar {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
        font-size: 10px;
    }

    .social-message-body {
        max-width: 78%;
    }

    .social-bubble {
        padding: 8px 10px 5px;
    }

    .social-bubble .chat-text {
        font-size: 14px;
    }

    .social-message-menu-panel {
        width: 190px;
        max-width: 70vw;
    }

    .inline-edit-text {
        min-width: 0;
        width: 58vw;
    }

    .social-chat-card .chat-form {
        border-radius: 0;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}


/* БРУ-АТЦ v20 realtime/loaders */
.nav-count { font-weight: 800; }

.loader-status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 16px;
}
.machine-card { margin: 0; }
.machine-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.machine-model { font-weight: 900; font-size: 19px; }
.machine-number { margin-top: 5px; font-size: 24px; font-weight: 900; }
.machine-status {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.machine-status-working { background:#e2f7e9; color:#176636; }
.machine-status-broken { background:#ffe5e1; color:#a42218; }
.machine-status-maintenance { background:#fff1cf; color:#805500; }
.machine-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 8px;
    margin: 16px 0;
    color: var(--muted);
    font-size: 13px;
}
.machine-meta > div { background:#f4f6f8; border-radius:10px; padding:10px; }
.machine-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.machine-status-btn.working { background:#147a4b; color:#fff; }
.machine-status-btn.broken { background:#b42318; color:#fff; }
.inline-toast {
    margin-bottom: 14px;
    padding: 10px 13px;
    border-radius: 10px;
    font-weight: 700;
}
.inline-toast.success { background:#e4f7e8; color:#176128; }
.inline-toast.error { background:#ffe5e5; color:#8a1111; }
.clear-chat-btn {
    margin-top: 12px;
    background:#b42318;
    color:#fff;
}
.maintenance-entry-card { border-left: 4px solid var(--primary); }

@media (max-width:640px) {
    .loader-status-grid { grid-template-columns:1fr; }
    .machine-head { flex-direction:column; }
    .machine-meta { grid-template-columns:1fr 1fr; }
}


/* БРУ-АТЦ v21 realtime counters */
.live-notification-stack {
    position: fixed;
    right: 16px;
    top: 76px;
    z-index: 10000;
    display: grid;
    gap: 9px;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
}

.live-notification-card {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid #d9e2e6;
    border-left: 4px solid #ff8618;
    border-radius: 12px;
    background: rgba(255,255,255,.98);
    color: #182027;
    box-shadow: 0 12px 32px rgba(0,0,0,.18);
    text-decoration: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: .2s ease;
    pointer-events: auto;
}

.live-notification-card.show {
    opacity: 1;
    transform: translateY(0);
}

.live-notification-card strong {
    font-size: 14px;
}

.live-notification-card span {
    font-size: 12px;
    line-height: 1.35;
    color: #5d6870;
}

@media (max-width: 640px) {
    .live-notification-stack {
        top: 66px;
        right: 8px;
        width: calc(100vw - 16px);
    }
}


/* БРУ-АТЦ v24 loader detail */
.machine-card-open {
    display: block;
    color: inherit;
    margin: -4px -4px 12px;
    padding: 4px;
    border-radius: 12px;
    transition: background .15s ease, transform .15s ease;
}

.machine-card-open:hover {
    background: #f7faf9;
}

.machine-card-open:active {
    transform: scale(.995);
}

.machine-history-link {
    margin-top: 13px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.loader-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.loader-detail-head h1 {
    margin: 8px 0 6px;
}

.back-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 800;
}

.loader-detail-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.loader-summary-card {
    margin: 0;
}

.loader-summary-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 7px;
}

.loader-summary-card strong {
    font-size: 24px;
}

.loader-driver-list {
    display: grid;
    gap: 9px;
}

.loader-driver-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 11px 12px;
    background: #f6f8f9;
    border-radius: 11px;
}

.loader-driver-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.loader-driver-row > span {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.section-title-row h2 {
    margin-bottom: 5px;
}

.section-title-row p {
    margin: 0;
}

.history-count {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #e8f4f1;
    color: #0c6f5f;
    font-weight: 900;
}

.maintenance-history-list {
    display: grid;
    gap: 12px;
}

.maintenance-history-item {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}

.maintenance-history-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.maintenance-type {
    font-size: 17px;
}

.maintenance-date {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.maintenance-hours {
    padding: 6px 9px;
    border-radius: 999px;
    background: #eef5f3;
    color: #0c6f5f;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.maintenance-description {
    margin-top: 11px;
    padding: 11px 12px;
    background: #f7f8fa;
    border-radius: 10px;
    line-height: 1.45;
}

.maintenance-history-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
    margin-top: 12px;
}

.maintenance-history-meta > div {
    padding: 9px 10px;
    background: #f7f8fa;
    border-radius: 10px;
}

.maintenance-history-meta span,
.maintenance-history-meta small {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.maintenance-history-meta strong {
    display: block;
    margin: 3px 0;
    font-size: 13px;
}

.empty-maintenance-history {
    min-height: 180px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    text-align: center;
    color: var(--muted);
}

.empty-maintenance-icon {
    font-size: 34px;
}

.empty-maintenance-history strong {
    color: var(--text);
}

@media (max-width: 640px) {
    .loader-detail-head {
        flex-direction: column;
    }

    .loader-detail-summary {
        grid-template-columns: 1fr;
    }

    .loader-driver-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .maintenance-history-meta {
        grid-template-columns: 1fr;
    }
}


/* БРУ-АТЦ v25 chat restrictions */
.restriction-list {
    display: grid;
    gap: 14px;
}

.restriction-card {
    margin-bottom: 0;
}

.restriction-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.restriction-card-head h2 {
    margin-bottom: 4px;
}

.restriction-type {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #fff0d5;
    color: #8f5a00;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}

.restriction-type.forever {
    background: #ffe4e1;
    color: #9d2118;
}

.restriction-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 9px;
    margin-top: 14px;
}

.restriction-grid > div,
.restriction-reason {
    padding: 10px 11px;
    border-radius: 10px;
    background: #f6f8f9;
}

.restriction-grid span,
.restriction-reason > span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
}

.restriction-grid strong {
    font-size: 13px;
}

.restriction-reason {
    margin-top: 9px;
}

.restriction-unmute-form {
    margin-top: 12px;
}

.empty-restrictions {
    min-height: 170px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    text-align: center;
    color: var(--muted);
}

.empty-restrictions > div {
    font-size: 34px;
}

.empty-restrictions strong {
    color: var(--text);
}

@media (max-width:640px) {
    .restriction-card-head {
        flex-direction: column;
    }

    .restriction-grid {
        grid-template-columns: 1fr;
    }
}
