:root {
  --bg: #07080a;
  --bg-2: #0d0f13;
  --bg-3: #14171d;
  --line: #22262e;
  --text: #e8eaee;
  --muted: #8a919e;
  --accent: #25d366;
  --accent-dim: rgba(37, 211, 102, 0.12);
  --danger: #ff5c5c;
  --radius: 12px;
  font-size: 15px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ── Marca ─────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.05rem; letter-spacing: 0.18em; font-weight: 800; }
.brand h1 span { color: var(--accent); font-weight: 300; margin-left: 6px; letter-spacing: 0.18em; }
.brand.small strong { letter-spacing: 0.18em; font-size: 0.72rem; color: var(--muted); }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 14px var(--accent);
}
.brand-dot.big { width: 16px; height: 16px; margin-bottom: 18px; }

/* ── Login ─────────────────────────────── */
.login-screen {
  height: 100vh; display: grid; place-items: center;
  background: radial-gradient(ellipse 70% 50% at 50% -10%, rgba(37,211,102,0.07), transparent), var(--bg);
}
.login-card {
  width: min(380px, 92vw); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 38px 34px; display: flex; flex-direction: column; gap: 16px;
}
.login-sub { color: var(--muted); font-size: 0.85rem; margin-top: -6px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--muted); }
input, textarea, .select {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-size: 0.95rem; font-family: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

.btn-primary {
  background: var(--accent); color: #04120a; font-weight: 700;
  border: none; border-radius: 10px; padding: 12px 20px;
  font-size: 0.95rem; cursor: pointer; transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { filter: grayscale(1) brightness(0.6); cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 16px; cursor: pointer; font-size: 0.85rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.chip {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 0.72rem; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.error { color: var(--danger); font-size: 0.82rem; }

/* ── Layout do app ─────────────────────── */
.app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; }

.sidebar { border-right: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-width: 0; }
.sidebar-head { padding: 18px 18px 12px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.me span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: 8px 4px; font-size: 0.78rem; cursor: pointer; border-radius: 8px;
}
.tab em { font-style: normal; background: var(--bg-3); border-radius: 999px; padding: 1px 7px; margin-left: 3px; font-size: 0.7rem; }
.tab.active { color: var(--text); background: var(--bg-3); font-weight: 600; }
.tab.active em { background: var(--accent-dim); color: var(--accent); }

.conversation-list { list-style: none; overflow-y: auto; flex: 1; }
.conversation-list li {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.conversation-list li:hover { background: var(--bg-3); }
.conversation-list li.active { background: var(--bg-3); border-left: 3px solid var(--accent); padding-left: 15px; }
.conv-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-name { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-badge {
  font-size: 0.66rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.conv-badge.queue { color: #ffc861; border-color: rgba(255,200,97,0.35); }
.conv-badge.mine { color: var(--accent); border-color: rgba(37,211,102,0.35); }
.conv-preview { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-unread {
  background: var(--accent); color: #04120a; font-weight: 700;
  border-radius: 999px; font-size: 0.68rem; padding: 1px 7px;
}

/* ── Chat ──────────────────────────────── */
.chat { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; line-height: 1.6; }
.chat-panel { display: flex; flex-direction: column; height: 100vh; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.chat-head h2 { font-size: 1rem; }
.chat-head p { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.chat-actions { display: flex; gap: 8px; align-items: center; }

.window-warning {
  background: rgba(255, 200, 97, 0.08); color: #ffc861;
  border-bottom: 1px solid rgba(255, 200, 97, 0.25);
  padding: 9px 22px; font-size: 0.8rem;
}

.messages { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 62%; padding: 10px 14px; border-radius: var(--radius); font-size: 0.92rem; line-height: 1.45; word-wrap: break-word; }
.msg.in { align-self: flex-start; background: var(--bg-3); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: #103e26; border: 1px solid #1b5c39; border-bottom-right-radius: 4px; }
.msg-meta { display: block; margin-top: 5px; font-size: 0.66rem; color: var(--muted); text-align: right; }
.msg.in .msg-meta { text-align: left; }

.send-form { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--bg-2); }
.send-form textarea { flex: 1; resize: none; max-height: 120px; }

/* ── Modal usuários ────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: grid; place-items: center; z-index: 50;
}
.modal-card {
  width: min(640px, 94vw); max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px;
}
.modal-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.users-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 22px; }
.users-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.72rem; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.users-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.users-table .inactive { opacity: 0.45; }
.user-form { display: flex; flex-direction: column; gap: 10px; }
.user-form h4 { font-size: 0.85rem; color: var(--muted); }
.user-form .row { display: flex; gap: 10px; }
.user-form .row > * { flex: 1; }

/* ── Toast ─────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 20px; font-size: 0.85rem; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toast.err { border-color: var(--danger); color: var(--danger); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .chat { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat { display: flex; }
}
