:root {
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #202c33;
  --line: #2a3942;
  --text: #e9edef;
  --muted: #8696a0;
  --out: #005c4b;
  --in: #202c33;
  --accent: #00a884;
  --danger: #f15c6d;
  --warn: #ffa726;
}

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

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(800px 320px at 50% 0%, rgba(0,168,132,.18), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 26px 24px;
  display: grid;
  gap: 12px;
}
.login-mark {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--accent); color: #052e24; font-weight: 900;
}
.login-card h1 { margin: 0; font-size: 1.35rem; }
.login-card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.45; }
.login-card label { display: grid; gap: 6px; font-size: .82rem; color: var(--muted); }
.login-card input, .login-card button, .search, .composer textarea, .ghost {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: .7rem .85rem;
}
.login-card button, .composer button {
  border: 0;
  background: var(--accent);
  color: #052e24;
  font-weight: 800;
  cursor: pointer;
}
.error { color: var(--danger); font-size: .85rem; }

.shell {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head, .thread-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.sidebar-head p, .thread-head p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.sidebar-head strong, .thread-head h2 { display: block; }
.thread-head h2 { margin: 0; font-size: 1rem; }
.ghost { cursor: pointer; font-size: .8rem; font-weight: 700; }
.side-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 0;
}
.nav-btn, .tab {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: .45rem .7rem;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.nav-btn.active, .tab.active {
  background: rgba(0,168,132,.16);
  border-color: rgba(0,168,132,.45);
  color: #9fe1d1;
}
.search { margin: 10px 12px; }
.history-box {
  margin: 0 12px 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  display: grid;
  gap: 8px;
}
.history-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.history-top strong { font-size: .82rem; }
.history-top p { margin: 3px 0 0; color: var(--muted); font-size: .72rem; }
.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
}
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }
.history-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.history-times label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.history-times input {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: .35rem .45rem;
}

.chats { flex: 1; overflow: auto; }
.chat {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid rgba(42, 57, 66, .55);
  background: transparent;
  color: inherit;
  padding: 12px 16px;
  cursor: pointer;
  display: grid;
  gap: 4px;
}
.chat:hover, .chat.active { background: #2a3942; }
.chat.phone-focus { box-shadow: inset 3px 0 0 var(--accent); }
.pill.phone {
  background: rgba(0, 168, 132, .18);
  color: #9fe1d1;
}
.follow-phone { margin-top: 2px; }
#phone-focus-line {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
}
.chat-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.chat-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-top time, .bubble time { color: var(--muted); font-size: .72rem; }
.preview {
  color: var(--muted);
  font-size: .84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill {
  display: inline-block;
  font-size: .68rem;
  font-weight: 800;
  color: var(--accent);
  border: 1px solid rgba(0,168,132,.35);
  border-radius: 999px;
  padding: 1px 7px;
  margin-right: 6px;
}

.thread { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.thread-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.badge {
  font-size: .72rem;
  font-weight: 800;
  color: var(--warn);
  border: 1px solid rgba(255,167,38,.35);
  border-radius: 999px;
  padding: .25rem .6rem;
}
.messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 8.5%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.03), transparent 55%),
    var(--bg);
}
.day {
  align-self: center;
  background: var(--panel-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .2rem .7rem;
  margin: 8px 0;
}
.bubble {
  max-width: 72%;
  padding: 7px 10px 5px;
  border-radius: 12px;
  display: grid;
  gap: 4px;
}
.bubble.me { align-self: flex-end; background: var(--out); border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--in); border-bottom-left-radius: 4px; }
.sender { color: #53bdeb; font-size: .75rem; font-weight: 700; }
.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: .95rem; line-height: 1.4; }
.media {
  color: #8eb8ad;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.media-box { min-width: 180px; }
.media-box audio,
.media-box video {
  width: 100%;
  max-width: 280px;
  display: block;
}
.media-thumb {
  max-width: min(280px, 100%);
  max-height: 360px;
  border-radius: 8px;
  display: block;
}
.media-sticker {
  width: 140px;
  height: auto;
  display: block;
}
.media-box .doc {
  color: #8eb8ad;
  font-weight: 700;
  word-break: break-all;
}
.bubble.deleted p { color: var(--muted); font-style: italic; }
.bubble p.was { color: var(--muted); font-style: italic; text-decoration: line-through; }
.reveal {
  border: 0;
  background: transparent;
  color: #8eb8ad;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
}
.foot { display: flex; justify-content: flex-end; gap: 8px; }
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 14px 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
}
.composer.is-disabled textarea, .composer.is-disabled button {
  opacity: .55;
  cursor: not-allowed;
}
.composer textarea { min-height: 44px; resize: none; }
.report { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.report-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
}
.report-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 24px;
  display: grid;
  align-content: start;
  gap: 8px;
}
.report-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  gap: 6px;
}
.report-item:hover { border-color: rgba(0,168,132,.45); }
.report-item .meta {
  color: var(--muted);
  font-size: .78rem;
}
.report-item .quote {
  color: var(--text);
  font-size: .95rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.report-item .quote.was { color: var(--muted); text-decoration: line-through; }
.report-empty { color: var(--muted); padding: 24px 8px; }
.bubble.edited .foot time::after { content: " · editada"; }
.jid-line { color: var(--muted); font-size: .72rem; word-break: break-all; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .shell.show-list .sidebar { display: flex; }
  .shell.show-list .thread { display: none; }
  .bubble { max-width: 88%; }
}
