:root {
    --bg: #0b141a;
    --surface: #111b21;
    --border: #2a3942;
    --text: #e9edef;
    --muted: #8696a0;
    --accent: #00a884;
    --error: #f15c6d;
    --font: "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.page-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.card--error {
    border-color: rgba(241, 92, 109, 0.45);
}

.card h1 {
    margin: 0 0 0.75rem;
    font-size: 1.35rem;
    font-weight: 600;
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

.code {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.8rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-main {
    flex: 1;
    padding: 1.5rem;
}

.panel {
    max-width: 720px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
}

.panel h1 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.panel--wide {
    max-width: 1100px;
}

/* ——— Lista de clientes ——— */
.clientes-meta {
    margin: 0.75rem 0 0;
}

.clientes-bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
    margin: 0.5rem 0 0;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.clientes-bulk-selectall {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.88rem;
}

.clientes-col-check {
    width: 2.25rem;
    text-align: center;
    vertical-align: middle;
}

.clientes-col-check input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.clientes-sqs-dialog__hint {
    margin: 0 0 0.75rem;
    font-size: 0.86rem;
    line-height: 1.45;
}

.clientes-sqs-dialog__hint code {
    font-size: 0.78em;
    word-break: break-word;
}

.clientes-sqs-dialog__preview-wrap {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
}

.clientes-sqs-dialog__preview {
    display: block;
    margin-top: 0.35rem;
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.clientes-table-wrap {
    margin-top: 0.75rem;
    overflow-x: auto;
}

.clientes-table td {
    vertical-align: middle;
}

.clientes-table__who {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 10rem;
}

.clientes-table__who .chat-avatar {
    flex-shrink: 0;
}

.clientes-table__name {
    font-weight: 500;
}

.clientes-table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.clientes-wa {
    font-size: 0.82em;
    word-break: break-all;
}

.btn--small {
    padding: 0.28rem 0.55rem;
    font-size: 0.82rem;
}

.clientes-table__email {
    max-width: 12rem;
    word-break: break-word;
    font-size: 0.86rem;
}

.clientes-import {
    margin: 1.25rem 0 1.5rem;
    padding: 1rem 1.1rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--bg);
}

.clientes-import__title {
    margin: 0 0 0.35rem;
    font-size: 1rem;
}

.clientes-import__hint {
    margin: 0 0 0.65rem;
    font-size: 0.86rem;
}

.clientes-import__textarea {
    width: 100%;
    box-sizing: border-box;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: inherit;
    resize: vertical;
    min-height: 6rem;
}

.clientes-import__actions {
    margin-top: 0.5rem;
}

.clientes-import__out {
    margin: 0.75rem 0 0;
    padding: 0.65rem 0.75rem;
    font-size: 0.78rem;
    max-height: 14rem;
    overflow: auto;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    word-break: break-word;
}

.clientes-filters {
    margin: 1rem 0 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
}

.clientes-filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
    gap: 0.65rem 0.85rem;
    align-items: end;
}

.clientes-filters__field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.clientes-filters__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.clientes-filters__input,
.clientes-filters__select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.45rem 0.55rem;
    font-size: 0.88rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.clientes-filters__input:focus,
.clientes-filters__select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.clientes-filters__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.clientes-filters__range-hint {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
}

.clientes-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.clientes-btn-tk--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    user-select: none;
}

.cliente-edit-tk-wrap {
    margin: 0 0 0.75rem;
}

.cliente-edit-tk-link {
    font-size: 0.88rem;
}

.cliente-edit-dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    padding: 0;
    max-width: 34rem;
    width: calc(100vw - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
}

.cliente-edit-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.cliente-edit-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.cliente-edit-dialog__title {
    margin: 0;
    font-size: 1.1rem;
}

.cliente-edit-dialog__close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.cliente-edit-dialog__close:hover {
    color: var(--text);
    background: var(--bg);
}

.cliente-edit-dialog__body {
    padding: 1rem 1.1rem;
    overflow-y: auto;
    max-height: min(70dvh, 28rem);
}

.cliente-edit-dialog__foot {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.cliente-edit-wa {
    margin: 0 0 0.75rem;
    font-size: 0.88rem;
}

.cliente-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.85rem;
}

.cliente-edit-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.cliente-edit-field > span {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.cliente-edit-field--span2 {
    grid-column: span 2;
}

.cliente-edit-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.45rem 0.55rem;
    font-size: 0.88rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

.cliente-edit-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.cliente-edit-msg {
    margin: 0.75rem 0 0;
    font-size: 0.86rem;
}

.cliente-edit-msg--error {
    color: var(--error);
}

@media (max-width: 520px) {
    .cliente-edit-grid {
        grid-template-columns: 1fr;
    }

    .cliente-edit-field--span2 {
        grid-column: span 1;
    }
}

.page-clientes .clientes-filters {
    flex-shrink: 0;
}

/* ——— Clientes: ecrã cheio + tabela rolável ——— */
.page-clientes {
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.page-clientes .topbar {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
}

.page-clientes .banner {
    flex-shrink: 0;
}

.page-clientes .app-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: clamp(0.2rem, 1vw, 0.65rem);
}

.page-clientes .panel.panel--wide {
    width: 100%;
    max-width: none;
    margin: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: clamp(0.45rem, 1.2vw, 1rem);
}

.page-clientes .panel > h1,
.page-clientes .panel > p {
    flex-shrink: 0;
}

.page-clientes .panel > h1 {
    margin-bottom: 0.25rem;
    font-size: clamp(1.05rem, 2.2vw, 1.2rem);
}

.page-clientes .panel > p.muted:first-of-type {
    margin-top: 0;
    margin-bottom: 0.35rem;
    font-size: 0.86rem;
    line-height: 1.35;
}

.page-clientes .clientes-import {
    flex-shrink: 0;
    margin-top: 0.5rem;
}

.page-clientes .clientes-import__textarea {
    min-height: clamp(2.75rem, 10vh, 5.5rem);
}

.page-clientes .clientes-filters {
    margin-top: 0.5rem;
    padding: 0.65rem 0.85rem;
}

.page-clientes .clientes-filters__grid {
    gap: 0.5rem 0.65rem;
}

.page-clientes .panel:has(.clientes-table-wrap) .clientes-meta {
    flex-shrink: 0;
    margin-top: 0.35rem;
}

.page-clientes .panel:has(.clientes-table-wrap) .clientes-bulk-bar {
    flex-shrink: 0;
}

.page-clientes .panel:has(.clientes-table-wrap) .clientes-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 0.35rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.page-clientes .clientes-table {
    width: 100%;
    min-width: max(100%, 720px);
}

@media (max-width: 640px) {
    .page-clientes .clientes-table {
        font-size: 0.76rem;
    }

    .page-clientes .modelo-batch-table.clientes-table th,
    .page-clientes .modelo-batch-table.clientes-table td {
        padding: 0.32rem 0.4rem;
    }

    .page-clientes .topbar strong {
        font-size: 0.95rem;
    }

    .page-clientes .topbar-nav {
        font-size: 0.88rem;
    }
}

@media (min-width: 768px) {
    .page-clientes .clientes-table {
        min-width: 900px;
    }
}

@media (min-width: 900px) {
    .page-clientes .app-main {
        padding: 0.5rem 0.5rem 0.65rem;
    }

    .page-clientes .panel.panel--wide {
        border-radius: 12px;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        max-width: min(100% - 0.35rem, 1920px);
        margin-inline: auto;
    }
}

/* ——— Chats (lista + thread) ——— */
.page-chats {
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.page-chats .topbar {
    flex-shrink: 0;
}

.page-chats .banner {
    flex-shrink: 0;
}

.banner {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.banner--error {
    background: rgba(241, 92, 109, 0.12);
    color: var(--error);
}

.chat-shell {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    overflow: hidden;
    border-top: 1px solid var(--border);
}

.chat-sidebar {
    width: 100%;
    max-width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.chat-sidebar__head {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-client-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.chat-client-list__empty {
    padding: 1rem 1.1rem;
    font-size: 0.9rem;
}

.chat-client-row {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.65rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    position: relative;
    padding-right: 2.5rem;
}

.chat-client-row:hover {
    background: rgba(42, 57, 66, 0.45);
    text-decoration: none;
}

.chat-client-row--active {
    background: #2a3942;
}

.chat-client-row .chat-avatar {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.chat-client-row__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chat-client-row__title {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-client-row__meta {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.chat-client-row__preview {
    display: block;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-badge {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #111b21;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cpath fill='%23182229' fill-opacity='0.35' d='M0 0h130v130H0zm130 130h130v130H130z'/%3E%3C/svg%3E");
    background-color: #0b141a;
}

.chat-main__head {
    padding: 0.65rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-placeholder {
    margin: 0;
    padding: 2rem 1.5rem;
    text-align: center;
}

.chat-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.chat-bubble {
    position: relative;
    max-width: min(78%, 520px);
    padding: 0.45rem 0.65rem 0.35rem;
    border-radius: 8px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.15);
}

.chat-bubble--in {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
}

.chat-bubble--out {
    align-self: flex-end;
    background: #005c4b;
    border: 1px solid #0a4a3f;
}

@keyframes chat-bubble-arrive {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-bubble--arrived {
    animation: chat-bubble-arrive 0.28s ease-out;
}

.chat-bubble__body {
    font-size: 0.92rem;
    word-break: break-word;
}

.chat-bubble__media-wrap {
    margin-bottom: 0.35rem;
}

.chat-bubble__media img,
.chat-bubble__media video {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    vertical-align: middle;
    display: block;
}

.chat-bubble__media--audio audio {
    width: 100%;
    max-width: 280px;
    min-height: 36px;
}

.chat-bubble__media--doc .chat-doc-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-bubble--out .chat-bubble__media--doc .chat-doc-link {
    color: #e9edef;
}

.chat-bubble__media--img.chat-bubble__media--failed {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.35;
}

.chat-bubble__media--img.chat-bubble__media--failed::after {
    content: 'Média indisponível (o URL da Meta pode ter expirado).';
}

.chat-bubble__text:empty {
    display: none;
}

.chat-quote-wrap {
    margin-bottom: 0.4rem;
}

.chat-quote {
    margin: 0;
    padding: 0.35rem 0.5rem;
    border-left: 3px solid #25d366;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.35;
}

.chat-bubble--out .chat-quote {
    background: rgba(0, 0, 0, 0.18);
    border-left-color: rgba(233, 237, 239, 0.65);
    color: rgba(233, 237, 239, 0.85);
}

.chat-quote--unknown {
    font-style: italic;
}

.chat-quote--jumpable {
    cursor: pointer;
}

.chat-quote--jumpable:hover {
    filter: brightness(1.06);
}

.chat-bubble--jump-flash {
    animation: chatJumpFlash 1.4s ease-out 1;
}

@keyframes chatJumpFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.65);
    }
    35% {
        box-shadow: 0 0 0 6px rgba(37, 211, 102, 0.35);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.chat-quote-wrap--reaction {
    margin-top: 0.35rem;
}

.chat-reaction {
    margin-bottom: 0.15rem;
}

.chat-reaction__row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.chat-reaction__label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-reaction__emoji {
    font-size: 1.85rem;
    line-height: 1;
}

.chat-bubble--out .chat-reaction__label {
    color: rgba(233, 237, 239, 0.8);
}

.chat-bubble--out .chat-reaction__emoji {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.chat-contact-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.chat-contact-card {
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.04);
    font-size: 0.88rem;
}

.chat-bubble--out .chat-contact-card {
    border-color: rgba(233, 237, 239, 0.35);
    background: rgba(0, 0, 0, 0.12);
}

.chat-contact-card__name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.chat-contact-card__phone {
    font-size: 0.82rem;
    line-height: 1.45;
    word-break: break-word;
}

.chat-contact-card__type {
    color: var(--muted);
    font-size: 0.78rem;
}

.chat-contact-card__tel,
.chat-contact-card__wa {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-bubble--out .chat-contact-card__tel,
.chat-bubble--out .chat-contact-card__wa {
    color: #e9edef;
}

.chat-contact-card__wa {
    margin-left: 0.15rem;
}

.chat-contact-card__wid {
    font-size: 0.72rem;
    display: inline-block;
    margin-left: 0.2rem;
}

.chat-bubble__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
    row-gap: 0.2rem;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    color: var(--muted);
    min-width: 0;
}

.chat-bubble__foot time {
    flex-shrink: 0;
}

.chat-bubble--out .chat-bubble__foot {
    color: rgba(233, 237, 239, 0.65);
}

.chat-bubble--out .chat-bubble__body {
    color: var(--text);
}

.chat-read {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.chat-read--no {
    color: #25d366;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.4);
}

.chat-read--yes {
    color: var(--muted);
}

.chat-read--out {
    color: rgba(233, 237, 239, 0.55);
}

.chat-main__head__row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.chat-main__head__text {
    flex: 1;
    min-width: 0;
}

.chat-main__head__actions {
    flex-shrink: 0;
}

.chat-tk-btn--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    user-select: none;
}

.chat-avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    vertical-align: middle;
}

.chat-avatar--sm {
    width: 40px;
    height: 40px;
}

.chat-avatar--md {
    width: 52px;
    height: 52px;
}

.chat-avatar__img {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar--has-img .chat-avatar__img {
    display: block;
}

.chat-avatar__fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 50%;
}

.chat-avatar--has-img .chat-avatar__fallback {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-window-banner {
    margin: 0;
    padding: 0.75rem 1rem;
    background: #1c2a32;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-window-banner--open {
    border-left: 3px solid var(--accent);
}

.chat-window-banner--closed {
    border-left: 3px solid var(--muted);
    opacity: 0.95;
}

.chat-window-banner__title {
    margin: 0 0 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.chat-window-banner__state {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.45;
}

.chat-window-banner__state--active {
    color: var(--text);
}

.chat-window-banner__state--inactive {
    color: var(--error);
}

.chat-window-banner__countdown {
    display: inline;
}

#chat-window-countdown {
    font-weight: 700;
    color: var(--accent);
    min-width: 4.5ch;
    display: inline-block;
}

.chat-composer {
    flex-shrink: 0;
    padding: 0.65rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.chat-composer__hint {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
}

.chat-composer__hint code {
    font-size: 0.78rem;
    color: var(--accent);
}

.chat-composer__form {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.chat-composer__row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-composer__text-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chat-composer__select {
    flex: 1;
    min-width: 12rem;
    max-width: 100%;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
}

.chat-composer__row--kind {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-composer__attach-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    flex-shrink: 0;
    max-width: min(11rem, 32vw);
}

.chat-composer__row--send .chat-composer__pending {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
}

.chat-composer__extras {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.chat-composer__text-row {
    display: flex;
    gap: 0.35rem;
    align-items: flex-end;
    width: 100%;
}

.chat-composer__text-row .chat-composer__input {
    flex: 1;
    min-width: 0;
}

.chat-composer__icon-btn {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
}

.chat-composer__icon-btn:hover:not(:disabled) {
    border-color: var(--accent);
}

.chat-composer__icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.text-emoji-panel {
    margin-top: 0.35rem;
    padding: 0.4rem 0.45rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
}

.text-emoji-panel__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.text-emoji-panel__btn {
    padding: 0.2rem;
    font-size: 1.2rem;
    line-height: 1;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.text-emoji-panel__btn:hover {
    background: rgba(0, 0, 0, 0.07);
}

.chat-composer__file-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.chat-composer__file-btn {
    flex-shrink: 0;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
}

.chat-composer__file-btn:hover:not(:disabled) {
    border-color: var(--accent);
}

.chat-composer__file-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-composer__file-btn--recording {
    border-color: #c62828;
    background: rgba(198, 40, 40, 0.08);
    color: #c62828;
}

.chat-composer__pending {
    font-size: 0.82rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-bubble--replyable {
    cursor: pointer;
}

.chat-bubble--replyable:hover {
    filter: brightness(1.02);
}

.chat-bubble--reply-target {
    z-index: 1;
    box-shadow:
        inset 0 0 0 2px #25d366,
        0 0 0 1px rgba(37, 211, 102, 0.45),
        0 1px 0.5px rgba(0, 0, 0, 0.15);
}

.chat-bubble--reply-target.chat-bubble--out {
    box-shadow:
        inset 0 0 0 2px #25d366,
        0 0 0 1px rgba(37, 211, 102, 0.35),
        0 1px 0.5px rgba(0, 0, 0, 0.15);
}

.chat-composer__input {
    flex: 1;
    min-height: 2.5rem;
    max-height: 8rem;
    resize: vertical;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
}

.chat-composer__input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-composer__input:disabled {
    opacity: 0.55;
}

.chat-composer__btn {
    flex-shrink: 0;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #111b21;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.chat-composer__btn:hover:not(:disabled) {
    filter: brightness(1.08);
}

.chat-composer__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-composer__status {
    margin: 0.4rem 0 0;
    min-height: 1.2em;
    font-size: 0.82rem;
    color: var(--error);
}

@media (max-width: 720px) {
    .chat-shell {
        flex-direction: column;
    }

    .chat-sidebar {
        max-width: none;
        flex: 0 0 auto;
        max-height: min(40vh, 300px);
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

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

/* ——— Topbar navegação (Conversas / Modelo) ——— */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-nav a.topbar-nav__active {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    cursor: default;
}

/* ——— Página Modelo (SQS + template) ——— */
.page-modelo {
    min-height: 100vh;
}

.page-modelo .modelo-main {
    padding: 1rem 1.25rem 2rem;
}

.modelo-section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.modelo-section:first-of-type {
    margin-top: 0.5rem;
    padding-top: 0;
    border-top: none;
}

.modelo-section__title {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.modelo-section__meta {
    margin: 0 0 0.75rem;
    font-size: 0.86rem;
}

.modelo-panel__intro {
    margin: 0 0 1rem;
    max-width: 52rem;
}

.modelo-panel__banner {
    margin: 0 0 0.75rem;
    border-radius: 8px;
}

.modelo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    border-color: var(--muted);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--accent);
    color: #111b21;
    border-color: transparent;
    font-weight: 600;
}

.btn--primary:hover:not(:disabled) {
    filter: brightness(1.08);
}

.btn--ghost {
    background: transparent;
}

.modelo-status {
    margin: 0 0 1rem;
    min-height: 1.25em;
    font-size: 0.88rem;
}

.modelo-status--error {
    color: var(--error);
}

.modelo-preview__title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.modelo-actions--start {
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.modelo-btn--wide {
    min-width: 8rem;
}

.modelo-batch-meta {
    margin: 0.25rem 0 0;
    font-size: 0.88rem;
}

.modelo-batch-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 0;
    font-size: 0.86rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.modelo-batch-table th,
.modelo-batch-table td {
    padding: 0.45rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.modelo-batch-table th {
    background: var(--bg);
    color: var(--muted);
    font-weight: 600;
}

.modelo-batch-table tr:last-child td {
    border-bottom: none;
}

.modelo-batch-table td:nth-child(3) {
    word-break: break-word;
    max-width: 22rem;
}
