* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.35 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; color: #111b21; background: #f0f2f5; }
a { color: #027eb5; }
button, input, textarea, select { font: inherit; }

/* Etiquetas */
.chip { display: inline-block; padding: 1px 7px; border-radius: 9px; font-size: 11px; font-weight: 600; background: #e9edef; color: #54656f; white-space: nowrap; }
.chip.t-aguardando { background: #fde2e1; color: #b3261e; }
.chip.t-pendente { background: #fff0c7; color: #8a6100; }
.chip.t-agendado { background: #dbeafe; color: #1d4ed8; }
.chip.t-aprovado, .chip.donor { background: #d9fdd3; color: #0a6b4d; }

/* Painel estilo WhatsApp */
.wa { display: flex; overflow: hidden; }
#list { width: 400px; max-width: 100%; display: flex; flex-direction: column; background: #fff; border-right: 1px solid #d1d7db; }
#list > header, #chat > header { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 14px; background: #008069; color: #fff; }
#list > header { justify-content: space-between; }
#list nav a { color: #fff; margin-left: 12px; font-size: 13px; text-decoration: none; opacity: .9; }
#search { margin: 8px 12px; padding: 8px 14px; border: 0; border-radius: 8px; background: #f0f2f5; outline: 0; }
#filters { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; }
#filters button { flex: none; padding: 5px 11px; border: 0; border-radius: 16px; background: #f0f2f5; color: #54656f; font-size: 13px; cursor: pointer; }
#filters button.on { background: #d9fdd3; color: #0a6b4d; font-weight: 600; }
#filters b:empty { display: none; }
#chats { flex: 1; overflow-y: auto; }
.row { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #f0f2f5; cursor: pointer; color: inherit; }
.row:hover, .row.on { background: #f0f2f5; }
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: grid; place-items: center; font-weight: 600; font-size: 18px; }
.row .mid { flex: 1; min-width: 0; }
.row strong, .row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row strong i { color: #0a6b4d; font-style: normal; }
.row small { color: #667781; margin: 1px 0 4px; }
.row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: #667781; }
.row .end b { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: #25d366; color: #fff; text-align: center; }
.none { padding: 30px; text-align: center; color: #667781; }

#chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #efeae2; }
#chat > header .avatar { width: 40px; height: 40px; }
#chat .who { min-width: 0; }
#chat .who strong { display: block; }
#chat .who small { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; opacity: .95; }
#back { display: none; border: 0; background: none; color: #fff; font-size: 22px; padding: 0 4px; }
#empty { margin: auto; color: #667781; }
#msgs { flex: 1; overflow-y: auto; padding: 14px 6%; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; margin: 8px 0; padding: 4px 10px; border-radius: 8px; background: #fff; color: #54656f; font-size: 12px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.msg { max-width: 72%; padding: 6px 9px; border-radius: 8px; background: #fff; align-self: flex-start; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: #d9fdd3; }
.msg p { margin: 0; white-space: pre-wrap; }
.msg em { display: block; font-style: normal; font-size: 12px; font-weight: 600; color: #008069; }
.msg img, .msg video { display: block; max-width: 100%; max-height: 320px; border-radius: 6px; margin-bottom: 4px; }
.msg audio { display: block; width: 260px; max-width: 100%; }
.msg .doc { display: block; padding: 8px; border-radius: 6px; background: rgba(0, 0, 0, .05); text-decoration: none; color: inherit; }
.msg time { display: block; text-align: right; font-size: 11px; color: #667781; }
.tick.read { color: #53bdeb; }
#composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; background: #f0f2f5; }
#composer[hidden], #chat > header[hidden], #msgs[hidden], #empty[hidden] { display: none; }
#composer textarea { flex: 1; resize: none; border: 0; border-radius: 20px; padding: 10px 14px; outline: 0; max-height: 120px; }
#composer button, .clip { flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center; font-size: 18px; cursor: pointer; }
#composer button { background: #008069; color: #fff; }
#composer.busy { opacity: .5; pointer-events: none; }

@media (max-width: 799px) {
    #list { width: 100%; border: 0; }
    #chat { display: none; }
    .in-chat #list { display: none; }
    .in-chat #chat { display: flex; }
    #back { display: block; }
    #msgs { padding: 10px; }
    .msg { max-width: 86%; }
}

/* Páginas simples: login, admin, relatórios */
.page { padding: 20px; max-width: 1100px; margin: 0 auto; }
.page > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page h1 { font-size: 22px; margin: 0; }
.page h2 { font-size: 17px; margin: 24px 0 10px; }
.card { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); margin-bottom: 16px; }
.login { display: grid; place-items: center; }
.login .card { width: 340px; max-width: 100%; display: grid; gap: 12px; }
.page label { display: grid; gap: 4px; font-size: 13px; color: #54656f; }
.page input, .page select { padding: 8px 10px; border: 1px solid #d1d7db; border-radius: 6px; background: #fff; }
.page button, .btn { padding: 9px 16px; border: 0; border-radius: 6px; background: #008069; color: #fff; cursor: pointer; text-decoration: none; display: inline-block; }
.error { color: #b3261e; margin: 0; }
.ok { color: #0a6b4d; }
.grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; }
.stats .card { flex: 1; min-width: 150px; margin: 0; }
.stats b { display: block; font-size: 28px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e9edef; text-align: left; white-space: nowrap; }
th { font-size: 12px; color: #54656f; text-transform: uppercase; }
td.num, th.num { text-align: right; }
.qr { max-width: 280px; display: block; }
.qr[hidden] { display: none; }
.code { font-size: 28px; font-weight: 700; letter-spacing: 3px; margin: 8px 0; }
.code:empty { display: none; }
.hint { color: #54656f; font-size: 13px; }
