.wa-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.wa-app {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.wa-app > .hub-view {
    flex: 1 1 auto;
    min-height: 0;
}

.wa-app .wa-toolbar {
    flex: 0 0 auto;
    min-height: 0;
}

.wa-app[hidden],
#waAuthGate[hidden],
.shell-head__actions[hidden],
.shell-head__nav[hidden],
#waPortalLogoutBtn[hidden],
#waOpenSessionBtn[hidden],
.wa-modal[hidden],
[hidden] {
    display: none !important;
}

body.is-locked .wa-app,
body.is-locked .shell-head__actions,
body.is-locked .shell-head__nav {
    display: none !important;
}

body.is-locked .shell-head p {
    color: var(--muted, #64748b);
}

.wa-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem 0.7rem;
    flex-wrap: wrap;
    padding: 0.35rem 0.55rem;
    min-height: 2.35rem;
}

.wa-toolbar__status {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.wa-toolbar__status strong {
    display: block;
    font-size: 0.84rem;
    line-height: 1.15;
}

.wa-toolbar__status p {
    margin: 0.02rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.2;
}

.wa-toolbar__accounts {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.wa-toolbar__accounts label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
}

.wa-toolbar__accounts select {
    min-width: 160px;
    height: 1.75rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: #fff;
}

.wa-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

.wa-dot[data-state="connected"] {
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.wa-dot[data-state="qr"],
.wa-dot[data-state="connecting"] {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.wa-dot[data-state="offline"],
.wa-dot[data-state="disconnected"] {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.wa-inline-error {
    margin: 0;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.82rem;
}

.wa-chat {
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: hidden;
    padding: 0;
}

.wa-chat-sidebar {
    border-right: 1px solid var(--border);
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.wa-chat-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.wa-new-chat {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.wa-new-chat input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.42rem 0.6rem;
    font-size: 0.84rem;
}

.wa-chat-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.wa-chat-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #eef2f7;
    background: transparent;
    text-align: left;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 0.55rem;
    align-items: center;
}

.wa-chat-item:hover,
.wa-chat-item.is-active {
    background: #ecfdf5;
}

.wa-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #dcfce7;
    color: #15803d;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.78rem;
}

.wa-chat-item__meta {
    min-width: 0;
}

.wa-chat-item__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.wa-chat-item__meta strong {
    font-size: 0.92rem;
    color: #0f172a;
}

.wa-chat-item__meta span {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-unread {
    background: #16a34a;
    color: #fff;
    border-radius: 999px;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wa-chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #efeae2;
}

.wa-chat-main__head {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.wa-chat-main__head strong {
    display: block;
    font-size: 0.92rem;
    line-height: 1.2;
}

.wa-chat-main__head p {
    margin: 0.1rem 0 0;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.3;
}

.wa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 0;
}

.wa-chat-empty {
    margin: auto;
    text-align: center;
    color: var(--muted);
    font-size: 0.86rem;
    padding: 0.75rem;
}

.wa-bubble {
    max-width: min(78%, 520px);
    padding: 0.45rem 0.65rem 0.28rem;
    border-radius: 10px;
    font-size: 0.86rem;
    line-height: 1.38;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06);
    white-space: pre-wrap;
    word-break: break-word;
}

.wa-bubble time {
    display: block;
    margin-top: 0.18rem;
    text-align: right;
    font-size: 0.64rem;
    opacity: 0.7;
}

.wa-bubble--in {
    align-self: flex-start;
    background: #fff;
    color: #0f172a;
    border-top-left-radius: 3px;
}

.wa-bubble--out {
    align-self: flex-end;
    background: #dcf8c6;
    color: #0f172a;
    border-top-right-radius: 3px;
}

.wa-chat-composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.4rem;
    padding: 0.5rem 0.65rem;
    border-top: 1px solid var(--border);
    background: #fff;
}

.wa-chat-composer input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.52rem 0.85rem;
    font-size: 0.88rem;
}

.wa-modal[hidden] {
    display: none !important;
}

.wa-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: grid;
    place-items: center;
    padding: 0.75rem;
}

.wa-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.wa-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 460px);
    max-height: min(92dvh, 720px);
    overflow: auto;
    padding: 0;
}

.wa-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

.wa-modal__head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
}

.wa-modal__close {
    border: 0;
    background: transparent;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}

.wa-modal__body {
    padding: 0.75rem 0.85rem 0.85rem;
    display: grid;
    gap: 0.7rem;
}

.wa-panel__status {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.wa-panel__status strong {
    display: block;
    font-size: 0.92rem;
}

.wa-panel__status p {
    margin: 0.08rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.wa-qr-wrap {
    width: min(100%, 240px);
    aspect-ratio: 1;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.wa-qr-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.wa-qr-placeholder {
    display: grid;
    gap: 0.35rem;
    place-items: center;
    color: var(--muted);
    text-align: center;
    padding: 0.75rem;
    font-size: 0.84rem;
}

.wa-qr-placeholder i {
    font-size: 1.7rem;
    color: #16a34a;
}

.wa-panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
}

.wa-steps {
    margin: 0;
    padding-left: 1.05rem;
    color: var(--muted);
    line-height: 1.4;
    font-size: 0.8rem;
}

.portal-dialog {
    z-index: 13000;
}

.portal-dialog__dialog {
    width: min(100%, 380px);
}

.portal-dialog__body {
    gap: 0.55rem;
}

.portal-dialog__message {
    margin: 0;
    color: var(--muted, #64748b);
    font-size: 0.86rem;
    line-height: 1.4;
}

.portal-dialog__input {
    width: 100%;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    font: inherit;
    font-size: 1.05rem;
    letter-spacing: 0.22em;
    text-align: center;
    background: #fff;
    box-sizing: border-box;
}

.portal-dialog__input[type="text"] {
    letter-spacing: normal;
    text-align: left;
    font-size: 0.9rem;
}

.portal-dialog__error {
    margin: 0;
    color: #b91c1c;
    font-size: 0.8rem;
    font-weight: 700;
}

.portal-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.15rem;
}

@media (max-width: 900px) {
    .wa-chat {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
        overflow: auto;
    }

    .wa-chat-sidebar {
        max-height: 36vh;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .wa-chat-main {
        min-height: 0;
        flex: 1 1 auto;
    }
}
