:root {
  /* Identidade Ponto. (extraída da apresentação oficial) */
  --brand: #003adb;
  --brand-dark: #00228a;
  --brand-deep: #001657;
  --brand-cyan: #00e5ff;
  --font-brand: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg: #f3f5fb;
  --panel: #ffffff;
  --border: #e1e5f0;
  --text: #141a2e;
  --muted: #667085;
  --accent: var(--brand);
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --bubble-in: #ffffff;
  --bubble-out: #dcfce7;
  --bubble-bot: #e0f2fe;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; margin: 0; }

h1, h2, h3, .btn, .nav, .seg, .chat-tenant, .tenant-badge { font-family: var(--font-brand); }
h1, h2 { font-weight: 700; letter-spacing: -0.3px; }

/* Botões e campos */
.btn { border: 1px solid var(--border); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f1f4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.btn.danger { color: var(--danger); border-color: #f5c2c2; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; }
textarea { resize: vertical; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .btn, .row > .shrink { flex: 0 0 auto; }
.stack { display: grid; gap: 10px; }

/* Login */
/* Login: fundo azul da marca com o símbolo "p." ao fundo, como na capa da apresentação */
.login {
  position: relative; overflow: hidden;
  display: grid; place-items: center; height: 100%; padding: 16px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
}
.login::before {
  content: ""; position: absolute; left: -8vh; bottom: -12vh; width: 70vh; height: 95vh;
  background: url("brand/simbolo-branco.png") no-repeat center / contain; opacity: .14; pointer-events: none;
}
.login-card { position: relative; }
.login-card { background: var(--panel); padding: 36px 32px 28px; border-radius: 18px; width: min(380px, 100%); display: grid; gap: 12px; text-align: center; box-shadow: 0 24px 60px rgba(0, 20, 90, .35); }
.login-card label { text-align: left; }
.login-logo { width: 190px; max-width: 70%; margin: 0 auto; display: block; }
.login-sub { font-family: var(--font-brand); color: var(--brand); font-size: 20px; letter-spacing: 1px; margin: -8px 0 10px; }

/* Layout */
.app { display: grid; grid-template-columns: 210px 1fr; height: 100%; }
.nav { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 55%, var(--brand-deep) 100%); color: #e5ebff; padding: 20px 12px; display: flex; flex-direction: column; gap: 22px; }
.nav-logo { width: 118px; margin: 0 8px; display: block; }
.nav nav { display: grid; gap: 2px; }
.nav nav button { text-align: left; background: none; border: 0; border-left: 3px solid transparent; color: #c9d6ff; padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.nav nav button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav nav button.active { background: rgba(255, 255, 255, .14); color: #fff; border-left-color: var(--brand-cyan); font-weight: 600; }
.nav .count { background: var(--brand-cyan); color: var(--brand-deep); font-weight: 700; border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.nav-footer { margin-top: auto; display: grid; gap: 6px; padding: 0 8px; }
.nav-footer .muted { color: #a9b9ee; }
.nav-footer .btn.ghost { color: #fff; justify-self: start; padding-left: 0; }
main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.page { padding: 20px 24px; overflow: auto; height: 100%; }
.page h1 { margin: 0 0 16px; font-size: 20px; }
.toolbar { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar label { min-width: 180px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }

/* Selo do cliente — identificação visual inconfundível */
.tenant-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white); padding: 1px 8px; border-radius: 99px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }

/* Atendimentos */
.inbox { display: grid; grid-template-columns: 340px 1fr 300px; height: 100%; min-height: 0; }
.queue { border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.queue .filters { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--border); }
.seg { display: flex; background: #f0f1f4; border-radius: 8px; padding: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 5px 4px; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.queue-list { overflow: auto; flex: 1; }
.conv { padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; border-left: 4px solid var(--c); display: grid; gap: 3px; }
.conv:hover { background: #f8f9fb; }
.conv.selected { background: color-mix(in srgb, var(--c) 7%, white); }
.conv .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv .name { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv .preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv time { color: var(--muted); font-size: 11px; flex: none; }
.unread { background: var(--ok); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.flag { color: var(--danger); font-size: 12px; font-weight: 600; }
.pill { font-size: 11px; border-radius: 99px; padding: 0 7px; background: #eef0f3; color: var(--muted); }
.pill.bot { background: #e0f2fe; color: #0369a1; }
.pill.closed { background: #f3f4f6; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Tempo de espera e dono da conversa */
.meta-line { margin-top: 2px; }
.wait { font-size: 11px; font-weight: 600; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.wait.ok { background: #e7f8ef; color: #047857; }
.wait.warn { background: #fef3c7; color: #92400e; }
.wait.late { background: #fee2e2; color: #b91c1c; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.owner { font-size: 11px; color: var(--muted); white-space: nowrap; }
.owner.me { color: var(--brand); font-weight: 600; }
.owner.none { color: #b45309; }
.pill.optout { background: #fff1e6; color: #9a3412; }
.chat-contact .actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.optout-toggle { color: var(--text); font-size: 13px; gap: 8px; }

/* Botões de template (como aparecem no WhatsApp do paciente) */
.tpl-buttons { display: grid; gap: 4px; margin-top: 6px; }
.tpl-buttons span { display: block; text-align: center; background: rgba(255,255,255,.75); border: 1px solid rgba(0,58,219,.18); color: var(--brand); border-radius: 6px; padding: 4px 8px; font-size: 12.5px; font-weight: 600; }
.wa-btn { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, white); }

/* Respostas rápidas */
.qr-wrap { position: relative; }
.qr-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 20, 90, .15); max-height: 320px; overflow: auto; z-index: 20; padding: 4px; }
.qr-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.qr-item:hover, .qr-item.active { background: color-mix(in srgb, var(--brand) 9%, white); }
.qr-item b { color: var(--brand); }
.qr-manage { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--border); background: none; padding: 8px 10px; color: var(--muted); cursor: pointer; font-size: 12px; margin-top: 4px; }
.qr-manage:hover { color: var(--brand); }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #efeae2; }
.chat-head { background: var(--panel); border-bottom: 1px solid var(--border); }
.chat-tenant { background: var(--c); color: #fff; padding: 6px 16px; font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; letter-spacing: .2px; }
.chat-contact { padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-contact strong { font-size: 15px; }
.messages { flex: 1; overflow: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 75%; padding: 7px 10px 5px; border-radius: 8px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0,0,0,.06); align-self: flex-start; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: var(--bubble-out); }
.msg.out.bot { background: var(--bubble-bot); }
.msg.failed { outline: 1px solid var(--danger); }
.msg .meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.msg .tpl { font-size: 10.5px; color: #0369a1; font-weight: 600; }
.anexo-previa { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg, #f6f7f9); }
.anexo-previa img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.anexo-previa .anexo-icone { font-size: 32px; width: 64px; text-align: center; flex: none; }
.anexo-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.anexo-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anexo-info span { font-size: 12px; color: var(--muted); }
.midia { margin: 2px 0 4px; font-size: 13px; color: var(--muted); }
.midia img { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 6px; cursor: zoom-in; }
.midia-sticker img { max-width: 140px; background: none; }
.midia audio { width: 260px; max-width: 100%; height: 40px; }
.midia video { display: block; max-width: min(320px, 100%); border-radius: 6px; }
.midia-doc { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; background: rgba(0,0,0,.05); color: inherit; text-decoration: none; }
.midia-doc span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.midia-doc small { color: #0369a1; font-weight: 600; }
.midia-carregando { font-style: italic; }
.midia-erro { color: var(--danger); }
.msg.note { align-self: center; background: #fff7d6; color: #7a5b00; font-size: 12px; max-width: 90%; text-align: center; }
.composer { background: var(--panel); border-top: 1px solid var(--border); padding: 10px 12px; display: grid; gap: 8px; }
.composer textarea { min-height: 42px; max-height: 160px; }
.window-warn { background: #fff7d6; color: #7a5b00; padding: 8px 10px; border-radius: 8px; font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }

.side { border-left: 1px solid var(--border); background: var(--panel); overflow: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
.side h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: #eef2ff; color: #3730a3; border-radius: 99px; padding: 1px 4px 1px 9px; font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.tag button { border: 0; background: none; cursor: pointer; color: #6366f1; padding: 0 4px; }
.appt { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: grid; gap: 4px; font-size: 13px; }
.appt .actions { display: flex; gap: 4px; flex-wrap: wrap; }

.status { font-size: 11px; font-weight: 600; border-radius: 99px; padding: 1px 8px; display: inline-block; }
.status.scheduled { background: #fef3c7; color: #92400e; }
.status.confirmed { background: #d1fae5; color: #065f46; }
.status.cancelled { background: #fee2e2; color: #991b1b; }
.status.done { background: #e0e7ff; color: #3730a3; }
.status.no_show { background: #f3f4f6; color: #4b5563; }

/* Agenda */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.slot { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--panel); cursor: pointer; text-align: left; display: grid; gap: 2px; min-height: 58px; }
.slot .time { font-weight: 700; }
.slot.free { border-color: #a7f3d0; background: #f0fdf4; }
.slot.free:hover { background: #dcfce7; }
.slot.busy { border-left: 4px solid var(--c); }
.slot.blocked { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 12px); }
.slot.past { opacity: .5; cursor: default; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* Lista de espera / tabelas */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.taglist button { display: flex; justify-content: space-between; width: 100%; text-align: left; }
.taglist button.active { background: #eef2ff; border-color: #c7d2fe; }

/* Modal e toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px; display: grid; gap: 14px; }
.modal h2 { margin: 0; font-size: 17px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; }
.pick-list { display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.pick-list button { text-align: left; }
.pick-list button.active { background: #eef2ff; border-color: #a5b4fc; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.2); display: grid; gap: 6px; }
.toast.error { background: var(--danger); }
.toast .btn { justify-self: start; }
.fab { position: fixed; left: 12px; bottom: 118px; z-index: 40; background: #25d366; color: #fff; border: 0; border-radius: 99px; padding: 10px 16px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.2); }

@media (max-width: 1200px) {
  .inbox { grid-template-columns: 300px 1fr; }
  .side { display: none; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nav { flex-direction: row; align-items: center; padding: 8px; overflow-x: auto; background: var(--brand); }
  .nav-logo { width: 72px; margin: 0 4px; flex: none; }
  .nav nav { display: flex; }
  .nav-footer { margin: 0; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-chat .queue { display: none; }
  .inbox:not(.has-chat) .chat { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* Caixinha de marcar com o texto ao lado */
.check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.check > input { flex: none; width: auto; margin: 0; }
