:root {
  font-family: Inter, "Segoe UI", sans-serif;
  color: #16332c;
  background: #eff4f1;
  --border: #dae5de;
  --muted: #526b62;
  --green: #14634c;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
p, h1, h2 { margin: 0; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.12rem; }
button, textarea { font: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
  color: inherit;
  border-radius: .65rem;
  padding: .65rem .9rem;
}
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.primary { background: var(--green); color: white; border-color: var(--green); }
.top {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: #123e33;
  color: white;
  padding: .85rem max(1rem, calc((100vw - 1220px) / 2));
}
.top p { color: #c3ddd1; font-size: .82rem; }
.brand-mark {
  background: #d0f2df;
  color: #123e33;
  display: grid;
  place-items: center;
  border-radius: .7rem;
  width: 2.5rem;
  height: 2.5rem;
  font-weight: 750;
}
main {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  max-width: 1220px;
  margin: 1.3rem auto;
  min-height: calc(100dvh - 112px);
  background: white;
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
}
aside { border-right: 1px solid var(--border); }
.queue-header, .chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
#count, #contact-status, #empty p, .list-note, #window-note { color: var(--muted); font-size: .88rem; }
#conversations { padding: .55rem; max-height: 72dvh; overflow: auto; }
.thread { display: grid; gap: .35rem; text-align: left; width: 100%; border-color: transparent; overflow-wrap: anywhere; }
.thread:hover, .thread[aria-current="true"] { background: #e5f3eb; }
.thread[aria-current="true"] { border-color: #a1cdb5; }
.thread small { color: var(--muted); }
.list-note { padding: .6rem; }
#empty { padding: 3rem 1.5rem; text-align: center; }
#empty p, #contact-status { margin-top: .35rem; }
.actions, .compose { display: flex; gap: .6rem; align-items: center; }
#summary {
  margin: 0;
  padding: .8rem 1rem;
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr;
  gap: .8rem;
  background: #f7faf8;
  overflow-wrap: anywhere;
}
dt { color: var(--muted); font-size: .78rem; }
dd { margin: .3rem 0 0; font-size: .9rem; }
#history {
  list-style: none;
  margin: 0;
  padding: 1rem;
  height: clamp(240px, 52dvh, 640px);
  overflow: auto;
  background: #eaf1ed;
}
.bubble {
  border-radius: .8rem;
  margin-bottom: .65rem;
  padding: .65rem .85rem;
  width: fit-content;
  max-width: 82%;
  background: white;
  overflow-wrap: anywhere;
}
.bubble.bot, .bubble.agent { margin-left: auto; background: #d7efdf; }
.bubble p { white-space: pre-wrap; }
.bubble small { display: block; margin-top: .35rem; color: var(--muted); }
#reply { padding: .75rem 1rem 1rem; }
#reply label { display: block; font-weight: 600; margin-bottom: .4rem; }
textarea { flex: 1; width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: .65rem; padding: .6rem; }
#window-note { padding: .65rem 1rem; }
#error { padding: .75rem 1rem; background: #fff0e8; color: #822f1a; }
@media (max-width: 650px) {
  main { grid-template-columns: 1fr; margin: .6rem; }
  aside { border: 0; border-bottom: 1px solid var(--border); }
  #conversations { max-height: 25dvh; }
  #summary { grid-template-columns: 1fr 1fr; }
  .actions { flex-wrap: wrap; justify-content: end; }
}

#account-nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
#signed-in { color: #d4e9df; font-size: .9rem; margin-right: .4rem; }
#account-nav button {
  min-height: 44px;
  padding: .55rem .85rem;
  background: #245648;
  color: #f4fbf7;
  border-color: #86b5a3;
  font-size: .9rem;
  font-weight: 600;
}
#account-nav button:hover { background: #306b59; }
#account-nav button[aria-current="page"] {
  background: #d0f2df;
  color: #123e33;
  border-color: #d0f2df;
}
#account-nav button[aria-current="page"]:hover { background: #e2f8eb; }
#account-nav #logout { background: transparent; margin-left: .25rem; }
#account-nav #logout:hover { background: #245648; }
#account-nav button:focus-visible { outline-color: #f4fbf7; }
.account-card, .settings-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.35rem;
  min-width: 0;
}
.account-card { max-width: 460px; margin: 2rem auto; }
.admin-grid { max-width: 1220px; margin: 1.3rem auto; display: grid; gap: 1rem; grid-template-columns: 1fr 1.15fr; align-items: start; }
.account-card h2, .settings-card h2 { margin-bottom: 1rem; }
.fields { display: grid; gap: .85rem; }
.fields > button { justify-self: start; }
.fields p, #recovery-view p, #new-access p { color: var(--muted); line-height: 1.45; }
.account-card label, .settings-card label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.account-card input, .settings-card input {
  width: 100%; border: 1px solid var(--border); border-radius: .55rem; color: inherit; background: white;
  font: inherit; font-weight: 400; padding: .65rem .75rem;
}
input[readonly] { background: #f2f7f4; }
#auth-feedback { color: #822f1a; margin-bottom: .75rem; }
#enroll-help { display: grid; gap: .65rem; }
#authenticator-qr { display: block; width: 220px; max-width: 100%; height: auto; justify-self: center; }
#enroll-help summary { cursor: pointer; color: var(--green); }
#enroll-help details p, #enroll-help details label { margin-top: .6rem; }
#callback-url { margin-bottom: 1rem; }
#new-access { background: #eaf5ee; border-radius: .75rem; padding: .8rem; margin-top: .75rem; display: grid; gap: .5rem; }
.users-list { list-style: none; padding: 0; margin: .9rem 0 0; display: grid; gap: .6rem; }
.users-list li { border-top: 1px solid var(--border); padding-top: .65rem; display: grid; gap: .5rem; }
.users-list small { color: var(--muted); overflow-wrap: anywhere; }
.users-list .actions { flex-wrap: wrap; }
#users-feedback, #whatsapp-feedback { margin-top: .5rem; overflow-wrap: anywhere; }
@media (max-width: 750px) {
  .admin-grid { grid-template-columns: 1fr; margin: .65rem; }
  .account-card { margin: 1rem auto; width: calc(100% - 1.3rem); }
  .top { flex-wrap: wrap; }
  #account-nav { margin-left: 0; }
}
