:root {
  --bg: #f3f4f7;
  --card: #fff;
  --line: #e3e7ee;
  --ink: #111827;
  --ink-strong: #0f172a;
  --muted: #6b7280;
  --muted-2: #4b5563;
  --accent: #128c7e;
  --active: #e7f8ef;
  --out: #d9f6e3;
  --err: #b42318;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; }

.brand { padding: 4px 8px 20px; line-height: 1; }
.brand-name { font-size: 26px; font-weight: 800; letter-spacing: 1px; color: var(--ink-strong); }
.brand-sub { font-size: 10px; letter-spacing: 3px; color: var(--accent); font-weight: 700; margin-top: 3px; }
.brand-center { text-align: center; padding-bottom: 24px; }

/* Login */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; }
.login-title { font-size: 20px; margin: 0 0 4px; text-align: center; color: var(--ink-strong); }
.login-sub { margin: 0 0 22px; text-align: center; color: var(--muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted-2); }
.field-input { height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
.field-input:focus, .search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-error { margin: 0; color: var(--err); font-size: 13px; }
.btn-primary { height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.btn-primary:hover { filter: brightness(.95); }
.login-foot { margin: 20px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* Painel */
.painel-page { overflow: hidden; }
.app { display: flex; height: 100vh; }
.sidebar { width: 240px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 10px; border-radius: 10px; text-align: left; color: var(--muted-2); font-weight: 600; }
.nav-item:hover { background: var(--bg); }
.nav-item.is-active { background: var(--active); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.status { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; padding: 0 10px; }
.demo-tag { margin: 0 10px; font-size: 11px; color: var(--muted); }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { border: 0; background: transparent; color: var(--muted); text-decoration: underline; padding: 0; }

.workspace { flex: 1; min-width: 0; display: flex; gap: 12px; padding: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.panel-head { height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.contacts { width: 320px; flex: none; }
.chat { flex: 1; min-width: 0; }
.info { width: 280px; flex: none; }
.qr { flex: 1; }
.info-title { margin: 0; font-size: 15px; color: var(--ink-strong); }

.search { display: flex; align-items: center; gap: 8px; padding: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.search-input { flex: 1; min-width: 0; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; background: var(--bg); }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:disabled { opacity: .6; }
.contact-list { flex: 1; overflow-y: auto; padding: 6px; }
.empty { color: var(--muted); text-align: center; padding: 24px 12px; margin: 0; }
.contact-row { width: 100%; display: flex; gap: 10px; align-items: center; border: 0; background: transparent; padding: 10px; border-radius: 10px; text-align: left; }
.contact-row:hover { background: var(--bg); }
.contact-row.is-selected { background: var(--active); }
.contact-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.contact-top { display: flex; justify-content: space-between; gap: 8px; }
.contact-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-time { font-size: 12px; color: var(--muted); flex: none; }
.contact-preview { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; min-width: 0; }
.contact-preview-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico { display: inline-flex; flex: none; }
.ico-accent { color: var(--accent); }

.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: #e5e7eb; color: var(--muted-2); }
.avatar-0 { background: #dbeafe; color: #1d4ed8; }
.avatar-1 { background: #fce7f3; color: #be185d; }
.avatar-2 { background: #fef3c7; color: #b45309; }
.avatar-3 { background: #ede9fe; color: #6d28d9; }

.chat-head-text { display: flex; flex-direction: column; min-width: 0; }
.chat-name { margin: 0; font-size: 15px; color: var(--ink-strong); }
.chat-sub { font-size: 12px; color: var(--muted); }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #f8f9fb; }
.day-chip { align-self: center; font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }
.bubble { max-width: 70%; padding: 8px 10px 6px; border-radius: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); }
.bubble.in { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--out); border-color: #bfe9cf; border-top-right-radius: 4px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-time { align-self: flex-end; font-size: 11px; color: var(--muted); }
.audio { display: flex; align-items: center; gap: 10px; }
.play { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.audio-mid { display: flex; flex-direction: column; gap: 4px; }
.wave { display: flex; align-items: center; gap: 2px; height: 30px; }
.wave-bar { width: 3px; border-radius: 2px; background: #9ca3af; }
.audio-time { font-size: 11px; color: var(--muted); }
.tx-toggle { align-self: flex-start; border: 0; background: transparent; padding: 0; color: var(--accent); font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.tx-toggle[aria-expanded="true"] .tx-chevron { transform: rotate(180deg); }
.tx-text { margin: 0; font-size: 13px; color: var(--muted-2); }
.composer-wrap { padding: 12px; border-top: 1px solid var(--line); }
.composer { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px 8px; }
.composer-input { flex: 1; min-width: 0; height: 36px; border: 0; background: transparent; font: inherit; }

@media (max-width: 1100px) { .info { display: none; } }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 8px; gap: 8px; }
  .brand { padding: 0 8px; }
  .nav { flex-direction: row; }
  .nav-label, .status, .demo-tag { display: none; }
  .sidebar-foot { margin-left: auto; margin-top: 0; }
  .user-row { border: 0; padding: 0; }
  .workspace { flex-direction: column; padding: 8px; }
  .contacts { width: 100%; max-height: 35vh; }
}
