* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: #f0f2f5;
  color: #111b21;
}
.hidden { display: none !important; }
.muted { color: #667781; }
.error { color: #d93025; min-height: 1em; }

header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: #075e54; color: #fff;
}
header h1 { margin: 0; font-size: 20px; }
nav { display: flex; gap: 4px; flex: 1; }
nav button { background: transparent; color: #d9fdd3; }
nav button.active { background: rgba(255,255,255,.18); color: #fff; }

main { max-width: 1100px; margin: 20px auto; padding: 0 12px; }
.card {
  background: #fff; border-radius: 10px; padding: 18px 20px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.card.narrow { max-width: 340px; margin: 15vh auto; display: flex; flex-direction: column; gap: 12px; }
h2 { font-size: 16px; margin: 18px 0 10px; }
h2:first-child { margin-top: 0; }

label { display: block; margin-bottom: 12px; }
label > input:not([type=checkbox]), label > textarea, label > .row { margin-top: 4px; }
input, textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d7db; border-radius: 6px;
  font: inherit; background: #fff;
}
textarea { resize: vertical; line-height: 1.5; }
input[type=range] { padding: 0; }
.switch { display: flex; align-items: center; gap: 8px; }
.switch input { width: auto; }
.row { display: flex; gap: 10px; align-items: center; }
.row > label { flex: 1; }

button {
  padding: 8px 16px; border: 0; border-radius: 6px; cursor: pointer;
  background: #00a884; color: #fff; font: inherit; white-space: nowrap;
}
button.ghost { background: #e9edef; color: #111b21; }
header button.ghost { background: rgba(255,255,255,.15); color: #fff; }
button.danger { background: #d93025; }
button.small { padding: 4px 10px; font-size: 13px; }

#qr { width: 280px; height: 280px; image-rendering: pixelated; }

.chats-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
@media (max-width: 800px) { .chats-layout { grid-template-columns: 1fr; } nav button { padding: 8px; } }
#chat-list { padding: 0; max-height: 75vh; overflow-y: auto; }
.chat-item { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.chat-item:hover, .chat-item.active { background: #f5f6f6; }
.chat-item .name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.chat-item .last { color: #667781; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #e9edef; font-weight: 400; }
.badge.pending { background: #fff3c4; }
.badge.off { background: #fde2e1; }

.messages {
  background: #efeae2; border-radius: 8px; padding: 12px; min-height: 200px;
  max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
}
.msg { max-width: 75%; padding: 6px 10px; border-radius: 8px; background: #fff; white-space: pre-wrap; align-self: flex-start; }
.msg.me { background: #d9fdd3; align-self: flex-end; }
.msg .meta { font-size: 11px; color: #667781; margin-top: 2px; }
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
