:root {
  --green: #0b6b43;
  --green-dark: #075333;
  --green-soft: #e8f5ef;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --line: #e1e8e4;
  --text: #173027;
  --muted: #718078;
  --danger: #b33a3a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; border: 0; }
.app { min-height: 100vh; }
.topbar { height: 70px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--green); color: white; display: grid; place-items: center; font-weight: 800; }
.brand strong { display: block; letter-spacing: .08em; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.primary { background: var(--green); color: white; padding: 11px 15px; border-radius: 10px; font-weight: 700; }
.primary:hover { background: var(--green-dark); }
.layout { display: grid; grid-template-columns: 230px 310px 1fr; height: calc(100vh - 70px); }
.numbers, .chats, .conversation { background: var(--panel); overflow: hidden; }
.numbers { border-right: 1px solid var(--line); padding: 14px 10px; }
.chats { border-right: 1px solid var(--line); }
.section-title { font-size: 12px; font-weight: 800; color: var(--muted); padding: 8px 10px 12px; text-transform: uppercase; letter-spacing: .06em; }
.number { padding: 12px 10px; border-radius: 10px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.number.active { background: var(--green-soft); }
.number .dot { width: 9px; height: 9px; border-radius: 50%; background: #a6b0ab; }
.number.connected .dot { background: #1a9b62; }
.number small { display: block; color: var(--muted); margin-top: 2px; }
.chat-header, .conversation-header { min-height: 68px; border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; }
.chat-header span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.chat-list { overflow: auto; height: calc(100% - 68px); }
.chat { padding: 13px 15px; border-bottom: 1px solid #f0f3f1; display: flex; gap: 10px; }
.chat:hover, .chat.active { background: #f7faf8; }
.avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); display: grid; place-items: center; font-weight: 800; }
.chat .meta { min-width: 0; flex: 1; }
.chat strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat p { margin: 4px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation { display: grid; grid-template-rows: 68px 1fr 68px; min-width: 0; }
.conversation-header { gap: 11px; }
.conversation-header > div:nth-child(2) { min-width: 0; flex: 1; }
.conversation-header span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.ghost { background: white; border: 1px solid var(--line); padding: 8px 10px; border-radius: 9px; color: var(--text); }
.messages { overflow: auto; padding: 20px; background: #f7faf8; }
.message { max-width: 70%; padding: 9px 11px; border-radius: 12px; margin: 6px 0; background: white; box-shadow: 0 1px 2px #0000000b; }
.message.me { margin-left: auto; background: var(--green-soft); }
.message time { display: block; text-align: right; color: var(--muted); font-size: 10px; margin-top: 3px; }
.composer { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; background: white; }
.composer input, label input { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none; }
.composer input { flex: 1; }
.send { background: var(--green); color: white; border-radius: 10px; padding: 0 17px; font-weight: 700; }
.send:disabled { opacity: .45; cursor: not-allowed; }
.empty { color: var(--muted); text-align: center; padding: 35px 18px; font-size: 14px; }
dialog { border: 0; border-radius: 16px; padding: 0; box-shadow: 0 20px 70px #0004; width: min(440px, calc(100vw - 30px)); }
dialog::backdrop { background: #06140ecc; }
.dialog-card { padding: 24px; position: relative; }
.dialog-card h2 { margin: 0 0 8px; }
.dialog-card p { color: var(--muted); line-height: 1.5; font-size: 14px; }
.dialog-card label { display: block; font-size: 13px; font-weight: 700; margin: 18px 0; }
.dialog-card label input { width: 100%; margin-top: 7px; }
.close { position: absolute; right: 12px; top: 10px; background: transparent; font-size: 26px; color: var(--muted); }
.qr-card { text-align: center; }
.qr-card img { width: 280px; max-width: 100%; margin: 12px auto; display: block; image-rendering: crisp-edges; }
#connectedMark { color: var(--green); font-weight: 800; padding: 20px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 190px 1fr; }
  .conversation { position: fixed; inset: 70px 0 0 190px; transform: translateX(100%); transition: transform .2s; z-index: 5; }
  .conversation.mobile-open { transform: translateX(0); }
}
@media (max-width: 650px) {
  .topbar { padding: 0 12px; }
  .topbar .primary { padding: 9px 10px; font-size: 12px; }
  .layout { grid-template-columns: 1fr; }
  .numbers { display: none; }
  .chats { border-right: 0; }
  .conversation { inset: 70px 0 0; }
}
