@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --papel: #05071F;                    /* fundo principal — navy muito escuro */
    --papel-escuro: #020310;             /* fundo secundário (sidebar) — quase preto-azulado */
    --tinta: #FFFFFF;                    /* texto principal, sobre fundo escuro */
    --tinta-suave: #9198C9;              /* texto secundário, branco-azulado suave */
    --linha: rgba(255, 255, 255, 0.13);  /* divisórias subtis sobre navy */
    --azulejo: #A30400;                  /* vermelho escuro/profundo — cor de destaque principal */
    --azulejo-claro: rgba(163, 4, 0, 0.22); /* hover/fundo suave sobre navy */
    --azulejo-glow: rgba(163, 4, 0, 0.5);  /* brilho — usado em box-shadow/text-shadow */
    --terracota: #A30400;                /* mesmo vermelho — erros/avisos/urgência */
    --sucesso: #FFFFFF;                  /* estados "concluído" — branco, calmo */
    --claro: #FFFFFF;                    /* branco puro */
    --texto-em-claro: #0A0C2E;           /* texto escuro, para usar sobre fundos brancos */
    --vermelho-suave-em-claro: #F7D8D5;  /* vermelho pálido, para usar sobre fundo branco */
    --corte: 16px;                       /* tamanho do corte angular dos painéis "HUD" */
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background-color: var(--papel); /* cor de reserva, caso o canvas demore a arrancar */
    color: var(--tinta);
    font-family: 'IBM Plex Sans', sans-serif;
    overflow: hidden;
}

#fundo-globo {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    display: block;
}

.app {
    display: flex;
    height: 100vh;
    height: 100dvh; /* conta corretamente com a barra de endereços em telemóveis */
    overflow: hidden;
    position: relative;
    z-index: 1;
    background: transparent;
}

/* Linha animada de "varrimento" no topo — assinatura visual futurista */
.app::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--azulejo) 35%, var(--claro) 50%, var(--azulejo) 65%, transparent);
    background-size: 200% 100%;
    animation: varrer 7s linear infinite;
    z-index: 100;
    opacity: 0.8;
    pointer-events: none;
}
@keyframes varrer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: rgba(2, 3, 16, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-right: 1px solid var(--linha);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--linha);
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
    transition: opacity 0.15s;
    position: relative;
}
.brand:hover { opacity: 0.85; }

.brand::before {
    content: '';
    position: absolute;
    top: 18px; left: 20px;
    width: 46px; height: 46px;
    background: radial-gradient(circle, rgba(163, 4, 0, 0.55), transparent 70%);
    filter: blur(6px);
    animation: respirar 3.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes respirar {
    0%, 100% { opacity: 0.5; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.15); }
}

.brand-mark {
    font-family: 'Source Serif 4', serif;
    font-weight: 700;
    font-size: 23px;
    color: var(--azulejo);
    letter-spacing: 0.04em;
    text-shadow: 0 0 18px var(--azulejo-glow), 0 0 40px rgba(163, 4, 0, 0.25);
    position: relative;
}

.brand-sub {
    font-size: 11px;
    color: var(--tinta-suave);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    position: relative;
}
.brand-sub::after {
    content: '▊';
    margin-left: 5px;
    color: var(--azulejo);
    animation: cursor-pisca 1.1s steps(1) infinite;
}
@keyframes cursor-pisca {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.sidebar-section {
    padding: 16px 16px 4px;
    border-bottom: 1px solid var(--linha);
}

.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--tinta-suave);
    margin-bottom: 10px;
}
.sidebar-heading span::before {
    content: '// ';
    color: var(--azulejo);
    opacity: 0.7;
}

.icon-btn {
    background: none;
    border: 1px solid var(--linha);
    border-radius: 4px;
    width: 20px;
    height: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--azulejo);
    font-size: 14px;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.icon-btn:hover {
    background: var(--azulejo-claro);
    border-color: var(--azulejo);
    box-shadow: 0 0 10px var(--azulejo-glow);
}
#btn-novo-utilizador {
    width: auto;
    padding: 0 6px;
    font-size: 11px;
}

.processo-list, .documento-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.processo-item {
    padding: 7px 10px;
    border-radius: 2px;
    font-size: 13px;
    cursor: pointer;
    color: var(--tinta);
    border-left: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.processo-item:hover { background: var(--azulejo-claro); }
.processo-item.ativo {
    background: linear-gradient(90deg, rgba(163, 4, 0, 0.4), rgba(163, 4, 0, 0.06));
    color: var(--claro);
    font-weight: 500;
    border-left: 2px solid var(--azulejo);
    box-shadow: 0 0 20px rgba(163, 4, 0, 0.25), inset 0 0 12px rgba(163, 4, 0, 0.1);
}

.processo-vazio {
    font-size: 12px;
    color: var(--tinta-suave);
    font-style: italic;
    padding: 4px 2px;
}

.documento-item {
    font-size: 11.5px;
    padding: 5px 8px;
    border-radius: 2px;
    color: var(--tinta-suave);
    font-family: 'IBM Plex Mono', monospace;
    word-break: break-all;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--linha);
    border-left: 2px solid var(--linha);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.documento-item:hover {
    border-color: var(--azulejo);
    border-left-color: var(--azulejo);
    box-shadow: 0 0 10px rgba(163, 4, 0, 0.25);
}

#input-estado-denuncia {
    width: 100%;
    margin-bottom: 12px;
    padding: 6px 8px;
    border: 1px solid var(--linha);
    border-radius: 6px;
    font-size: 12.5px;
    font-family: 'IBM Plex Sans', sans-serif;
    background: var(--claro);
    color: var(--texto-em-claro);
}

.dropzone {
    border: 1.5px dashed var(--linha);
    padding: 18px 10px;
    text-align: center;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    clip-path: polygon(12px 0, 100% 0, 100% 100%, 0 100%, 0 12px);
}
.dropzone:hover, .dropzone.arrasto-ativo {
    border-color: var(--azulejo);
    background: var(--azulejo-claro);
    box-shadow: 0 0 26px rgba(163, 4, 0, 0.22), inset 0 0 24px rgba(163, 4, 0, 0.08);
}
.dropzone-icon {
    font-size: 20px;
    color: var(--azulejo);
    line-height: 1;
    margin-bottom: 4px;
    text-shadow: 0 0 12px var(--azulejo-glow);
}
.dropzone p {
    margin: 2px 0;
    font-size: 12.5px;
    color: var(--tinta);
}
.dropzone-sub {
    font-size: 10.5px !important;
    color: var(--tinta-suave) !important;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 16px;
}

/* ---------- Main ---------- */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 30px 16px 28px;
    border-bottom: 1px solid var(--linha);
    background: rgba(5, 7, 31, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%);
}

.topbar h1 {
    font-family: 'Source Serif 4', serif;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--tinta);
}

.topbar-sub {
    font-size: 12.5px;
    color: var(--tinta-suave);
    margin: 2px 0 0;
    font-family: 'IBM Plex Mono', monospace;
}

.indicador-ligacao {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10.5px;
    color: var(--sucesso);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}
.indicador-ligacao.a-processar {
    color: var(--azulejo);
    text-shadow: 0 0 12px var(--azulejo-glow);
    animation: pulso-estado 0.9s infinite ease-in-out;
}
@keyframes pulso-estado {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.conversa {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.mensagem-sistema {
    font-size: 13.5px;
    color: var(--tinta-suave);
    background: rgba(2, 3, 16, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid var(--linha);
    border-left: 2px solid var(--azulejo);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    max-width: 640px;
}
.mensagem-sistema p { margin: 0; }

.bolha {
    max-width: 720px;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.55;
}

.bolha-utilizador {
    align-self: flex-end;
    background: var(--azulejo);
    color: var(--claro);
    box-shadow: 0 0 30px rgba(163, 4, 0, 0.32);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
}

.bolha-assistente {
    align-self: flex-start;
    background: var(--claro);
    color: var(--texto-em-claro);
    border: 1px solid var(--linha);
    max-width: 760px;
    box-shadow: 0 4px 28px rgba(0, 0, 0, 0.4);
    clip-path: polygon(16px 0, 100% 0, 100% 100%, 0 100%, 0 16px);
    position: relative;
}

.bolha-assistente h1, .bolha-assistente h2, .bolha-assistente h3 {
    font-family: 'Source Serif 4', serif;
    margin: 0.6em 0 0.3em;
    color: var(--texto-em-claro);
}
.bolha-assistente h1:first-child, .bolha-assistente h2:first-child, .bolha-assistente h3:first-child {
    margin-top: 0;
}
.bolha-assistente p { margin: 0.5em 0; }
.bolha-assistente ul, .bolha-assistente ol { margin: 0.4em 0; padding-left: 22px; }
.bolha-assistente table {
    border-collapse: collapse;
    font-size: 13px;
    margin: 0.6em 0;
}
.bolha-assistente th, .bolha-assistente td {
    border: 1px solid #D8DAEF;
    padding: 5px 9px;
}
.bolha-assistente code {
    background: var(--vermelho-suave-em-claro);
    color: var(--azulejo);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
}

/* Carimbos — indicam que agentes foram acionados */
.carimbos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.carimbo {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1.5px solid var(--azulejo);
    color: var(--azulejo);
    background: var(--claro);
    border-radius: 999px;
    padding: 3px 10px 3px 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transform: rotate(-1deg);
    box-shadow: 0 0 12px rgba(163, 4, 0, 0.35);
}

.a-pensar {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 4px;
}
.a-pensar span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--azulejo);
    box-shadow: 0 0 8px var(--azulejo-glow);
    animation: pulsar 1.2s infinite ease-in-out;
}
.a-pensar span:nth-child(2) { animation-delay: 0.2s; }
.a-pensar span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulsar {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.erro-mensagem {
    align-self: flex-start;
    background: rgba(163, 4, 0, 0.16);
    border: 1px solid var(--terracota);
    color: var(--tinta);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    max-width: 640px;
    box-shadow: 0 0 24px rgba(163, 4, 0, 0.22);
}

.input-area {
    display: flex;
    gap: 10px;
    padding: 16px 28px 22px;
    border-top: 1px solid var(--linha);
    background: rgba(5, 7, 31, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

#input-mensagem {
    flex: 1;
    resize: none;
    border: 1px solid var(--linha);
    border-radius: 8px;
    padding: 11px 14px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
    background: var(--claro);
    color: var(--texto-em-claro);
    max-height: 160px;
    transition: box-shadow 0.15s, border-color 0.15s;
}
#input-mensagem:focus {
    outline: none;
    border-color: var(--azulejo);
    box-shadow: 0 0 0 3px rgba(163, 4, 0, 0.2);
}

/* Botão primário — painel com cantos cortados + anel de energia rotativo ao passar o rato */
.botao-primario {
    position: relative;
    background: var(--azulejo);
    color: var(--claro);
    border: none;
    padding: 0 22px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'IBM Plex Sans', sans-serif;
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
    transition: box-shadow 0.2s, opacity 0.2s;
    isolation: isolate;
}
.botao-primario::before {
    content: '';
    position: absolute;
    inset: -3px;
    z-index: -1;
    background: conic-gradient(from 0deg, transparent 0%, var(--azulejo) 15%, var(--claro) 25%, var(--azulejo) 35%, transparent 55%);
    opacity: 0;
    transition: opacity 0.25s;
    animation: rodar-anel 2.2s linear infinite;
}
.botao-primario:hover::before { opacity: 1; }
.botao-primario:hover { box-shadow: 0 0 26px rgba(163, 4, 0, 0.55); }
.botao-primario:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.botao-primario:disabled::before { display: none; }
@keyframes rodar-anel { to { transform: rotate(360deg); } }

.botao-secundario {
    width: 100%;
    background: none;
    border: 1px solid var(--azulejo);
    color: var(--azulejo);
    padding: 8px;
    font-size: 12.5px;
    cursor: pointer;
    margin: 4px 0 14px;
    font-family: 'IBM Plex Sans', sans-serif;
    clip-path: polygon(8px 0, 100% 0, 100% 100%, 0 100%, 0 8px);
    transition: box-shadow 0.15s, background 0.15s;
}
.botao-secundario:hover {
    background: var(--azulejo-claro);
    box-shadow: 0 0 16px rgba(163, 4, 0, 0.35);
}

.botao-fantasma {
    width: 100%;
    background: none;
    border: none;
    color: var(--tinta-suave);
    padding: 8px;
    font-size: 12.5px;
    cursor: pointer;
    text-align: left;
    font-family: 'IBM Plex Sans', sans-serif;
}
.botao-fantasma:hover { color: var(--tinta); }

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal[hidden] {
    display: none;
}
.modal-caixa {
    position: relative;
    background: rgba(2, 3, 16, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(163, 4, 0, 0.35);
    padding: 26px;
    width: 340px;
    box-shadow: 0 0 60px rgba(163, 4, 0, 0.18), 0 10px 40px rgba(0, 0, 0, 0.55);
    clip-path: polygon(var(--corte) 0, 100% 0, 100% calc(100% - var(--corte)), calc(100% - var(--corte)) 100%, 0 100%, 0 var(--corte));
}
/* Marcas HUD nos cantos — moldura de "alvo" */
.modal-caixa::before, .modal-caixa::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    border: 2px solid var(--azulejo);
    filter: drop-shadow(0 0 5px var(--azulejo-glow));
    pointer-events: none;
}
.modal-caixa::before {
    top: -1px; left: -1px;
    border-right: none; border-bottom: none;
}
.modal-caixa::after {
    bottom: -1px; right: -1px;
    border-left: none; border-top: none;
}
.modal-caixa-larga {
    width: 460px;
    max-height: 88vh;
    overflow-y: auto;
}
.modal-caixa h2 {
    font-family: 'Source Serif 4', serif;
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--tinta);
}
.modal-caixa p {
    font-size: 13px;
    color: var(--tinta-suave);
    margin: 0 0 14px;
}
.modal-caixa input, .modal-caixa select, .modal-caixa textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--linha);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    font-family: 'IBM Plex Sans', sans-serif;
    background: var(--claro);
    color: var(--texto-em-claro);
}
.modal-caixa textarea { resize: vertical; min-height: 70px; }

.campo-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tinta-suave);
    margin-bottom: 6px;
}
.campo-linha {
    display: flex;
    gap: 12px;
}
.campo-coluna { flex: 1; }

.radio-grupo {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
    color: var(--tinta);
}
.radio-grupo label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.radio-grupo input { width: auto; margin: 0; }

.modal-acoes {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-acoes .botao-fantasma { width: auto; }

.modal-caixa-documento {
    width: 80vw;
    max-width: 900px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.modal-documento-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--linha);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12.5px;
    color: var(--tinta);
    word-break: break-all;
    flex-shrink: 0;
}
.modal-documento-acoes {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    margin-left: 12px;
}
.botao-fantasma-inline {
    background: none;
    border: none;
    color: var(--tinta-suave);
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    font-family: 'IBM Plex Sans', sans-serif;
    white-space: nowrap;
}
.botao-fantasma-inline:hover { color: var(--claro); }
.modal-documento-corpo {
    flex: 1;
    overflow: auto;
    background: var(--claro);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-documento-corpo iframe {
    width: 100%;
    height: 100%;
    border: none;
}
.modal-documento-corpo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.modal-documento-sem-preview {
    padding: 40px;
    text-align: center;
    color: var(--texto-em-claro);
    font-size: 14px;
}
.modal-documento-sem-preview a {
    color: var(--azulejo);
    font-weight: 600;
}

/* ---------- Denúncias ---------- */
.denuncia-list .processo-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding-top: 8px;
    padding-bottom: 8px;
}
.denuncia-linha-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
}
.denuncia-assunto {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.btn-apagar-denuncia {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--tinta-suave);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: 0.6;
}
.btn-apagar-denuncia:hover {
    color: var(--terracota);
    opacity: 1;
}

.processo-linha-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.processo-nome {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.linha-acoes-item {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.btn-transferir-item {
    background: none;
    border: none;
    color: var(--tinta-suave);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: 0.6;
}
.btn-transferir-item:hover {
    color: var(--azulejo);
    opacity: 1;
}

.denuncia-linha-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
}
.tag-estado {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid currentColor;
}
.tag-aberta { color: var(--azulejo); box-shadow: 0 0 8px rgba(163, 4, 0, 0.4); }
.tag-em_curso { color: var(--tinta); }
.tag-resolvida { color: var(--sucesso); background: rgba(255, 255, 255, 0.12); }

.denuncia-prazo {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--tinta-suave);
}
.denuncia-prazo.atrasado { color: var(--azulejo); font-weight: 600; }

/* ---------- Calendário ---------- */
.calendario-cabecalho {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tinta);
}
.calendario-nav {
    background: none;
    border: 1px solid var(--linha);
    color: var(--azulejo);
    width: 20px; height: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 3px;
    font-size: 13px;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.calendario-nav:hover {
    background: var(--azulejo-claro);
    border-color: var(--azulejo);
    box-shadow: 0 0 8px var(--azulejo-glow);
}

.calendario-dias-semana {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    color: var(--tinta-suave);
    margin-bottom: 4px;
}

.calendario-grelha {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 14px;
}

.calendario-dia {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--tinta-suave);
    cursor: pointer;
    border-radius: 3px;
    position: relative;
    transition: background 0.15s, box-shadow 0.15s;
}
.calendario-dia:hover:not(.vazio) {
    background: var(--azulejo-claro);
    box-shadow: 0 0 10px rgba(163, 4, 0, 0.2);
}
.calendario-dia.vazio { cursor: default; }
.calendario-dia.hoje {
    border: 1px solid var(--azulejo);
    color: var(--tinta);
    font-weight: 600;
}
.calendario-dia .pontos {
    display: flex;
    gap: 2px;
    margin-top: 2px;
    height: 4px;
}
.calendario-dia .ponto {
    width: 4px; height: 4px;
    border-radius: 50%;
}
.calendario-dia .ponto.prazo_denuncia {
    background: var(--azulejo);
    box-shadow: 0 0 4px var(--azulejo-glow);
}
.calendario-dia .ponto.compromisso { background: var(--tinta); }

.modal-dia-lista {
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.modal-dia-vazio {
    font-size: 12.5px;
    color: var(--tinta-suave);
    font-style: italic;
}
.evento-item {
    padding: 8px 10px;
    border-radius: 4px;
    border-left: 2px solid var(--linha);
    background: rgba(255, 255, 255, 0.04);
    font-size: 12.5px;
}
.evento-item.prazo_denuncia { border-left-color: var(--azulejo); }
.evento-item.compromisso { border-left-color: var(--claro); }
.evento-linha-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.evento-hora {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--azulejo);
    font-size: 11px;
    margin-right: 6px;
}
.evento-titulo { color: var(--tinta); }
.evento-descricao { color: var(--tinta-suave); font-size: 11.5px; margin-top: 4px; }
.evento-ligado { font-size: 10.5px; color: var(--tinta-suave); font-style: italic; margin-top: 4px; }
.btn-apagar-evento {
    background: none;
    border: none;
    color: var(--tinta-suave);
    cursor: pointer;
    font-size: 13px;
    opacity: 0.6;
    flex-shrink: 0;
}
.btn-apagar-evento:hover { color: var(--terracota); opacity: 1; }

/* ---------- Login ---------- */
.login-pagina {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-caixa {
    position: relative;
    background: rgba(2, 3, 16, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(163, 4, 0, 0.35);
    padding: 32px 30px 28px;
    width: 320px;
    box-shadow: 0 0 60px rgba(163, 4, 0, 0.18), 0 10px 40px rgba(0, 0, 0, 0.55);
    clip-path: polygon(var(--corte) 0, 100% 0, 100% calc(100% - var(--corte)), calc(100% - var(--corte)) 100%, 0 100%, 0 var(--corte));
}
.login-caixa::before, .login-caixa::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    border: 2px solid var(--azulejo);
    filter: drop-shadow(0 0 5px var(--azulejo-glow));
    pointer-events: none;
}
.login-caixa::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.login-caixa::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }
.login-caixa form {
    margin-top: 20px;
}
.login-botao {
    width: 100%;
    height: 40px;
    margin-top: 6px;
}
.login-erro {
    color: var(--azulejo);
    font-size: 12.5px;
    background: rgba(163, 4, 0, 0.14);
    border: 1px solid var(--terracota);
    border-radius: 4px;
    padding: 8px 10px;
    margin: 14px 0 0;
}

/* Cabeçalho de utilizador + admin "ver como", na topbar */
.utilizador-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--tinta-suave);
}
.utilizador-nome { color: var(--tinta); }
.tag-admin {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--azulejo);
    border: 1px solid var(--azulejo);
    border-radius: 999px;
    padding: 1px 6px;
}
#seletor-ver-como {
    background: var(--papel-escuro);
    color: var(--tinta);
    border: 1px solid var(--linha);
    border-radius: 4px;
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
    padding: 3px 6px;
}
.link-logout {
    color: var(--tinta-suave);
    text-decoration: none;
    font-size: 11px;
}
.link-logout:hover { color: var(--azulejo); }

/* Scrollbars — vidro escuro com brilho vermelho */
.sidebar::-webkit-scrollbar, .conversa::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .conversa::-webkit-scrollbar-thumb {
    background: rgba(163, 4, 0, 0.4);
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover, .conversa::-webkit-scrollbar-thumb:hover {
    background: rgba(163, 4, 0, 0.65);
}

/* ---------- Botão de menu móvel (escondido em ecrãs largos) ---------- */
.btn-menu-movel {
    display: none;
    background: none;
    border: 1px solid var(--linha);
    color: var(--tinta);
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-menu-movel:hover { background: var(--azulejo-claro); }

.sidebar-overlay {
    display: none;
}

@media (max-width: 720px) {
    .btn-menu-movel { display: block; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 82vw;
        max-width: 320px;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    .sidebar.aberta {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 55;
    }
    .sidebar-overlay[hidden] { display: none; }

    .topbar { padding: 12px 14px; }
    .topbar h1 { font-size: 16px; }
    .topbar-sub { font-size: 11px; }
    .utilizador-nome, .tag-admin { display: none; } /* poupa espaço — o "ver como" e "Sair" mantêm-se visíveis */
    #seletor-ver-como {
        display: block;
        max-width: 92px;
        font-size: 11px;
        padding: 3px 4px;
    }
    .link-logout { font-size: 12px; }
    #btn-novo-utilizador { display: none; }

    .conversa { padding: 16px 14px; }
    .bolha { max-width: 88%; }
    .input-area { padding: 12px 14px 16px; gap: 8px; }
    #input-mensagem { font-size: 16px; } /* 16px evita o zoom automático do iOS ao focar */

    .modal-caixa,
    .modal-caixa-larga {
        width: 90vw;
        max-width: 400px;
        padding: 20px;
        max-height: 85vh;
    }
    .modal-caixa-documento {
        width: 94vw;
        height: 88vh;
    }
    .campo-linha { flex-direction: column; gap: 0; }

    .calendario-dia { font-size: 10px; }
}

@media (max-width: 400px) {
    .bolha { max-width: 94%; font-size: 13.5px; }
    .brand-mark { font-size: 20px; }
}
