:root {
  color-scheme: light;
  --ink: #202537;
  --muted: #8a90a1;
  --line: #eceef3;
  --surface: #fff;
  --canvas: #f5f7fb;
  --primary: #6258d9;
  --primary-dark: #5147c6;
  --primary-soft: #f0efff;
  --green: #2eaa7a;
  font-family: 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 360px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  display: flex;
  width: 248px;
  flex-direction: column;
  padding: 27px 17px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 10px 49px;
  color: var(--ink);
  font: 800 21px 'Manrope', sans-serif;
  letter-spacing: -1px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, #7a70ed, #5147c6);
  color: #fff;
  font-size: 19px;
  letter-spacing: -1px;
  box-shadow: 0 5px 12px #6258d933;
}

.main-nav { display: grid; gap: 7px; }

.nav-item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 9px;
  color: #747b8e;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-icon { width: 19px; text-align: center; font-size: 17px; }
.nav-count { margin-left: auto; font-size: 11px; }

.sidebar-bottom { margin-top: auto; }

.connection-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 10px;
  border: 1px solid #f0e2c7;
  border-radius: 9px;
  background: #fffbf3;
}

.connection-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: #e4a43b;
}

.connection-card strong, .connection-card span:last-child { display: block; }
.connection-card strong { margin-bottom: 4px; font-size: 11px; }
.connection-card div span { color: #918a7f; font-size: 10px; }

.profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 3px 0;
  border-top: 1px solid var(--line);
}

.profile-copy { display: grid; gap: 3px; min-width: 0; }
.profile-copy strong { font-size: 11px; }
.profile-copy small { color: var(--muted); font-size: 10px; }
.profile .icon-button { margin-left: auto; }

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font: 700 12px 'Manrope', sans-serif;
}

.avatar-user { width: 31px; height: 31px; background: #d7d4ff; color: #5147c6; }
.avatar-rose { background: #e999a7; }
.avatar-blue { background: #7aa4d8; }
.avatar-orange { background: #e6a367; }
.avatar-green { background: #78b9a2; }

.workspace { width: calc(100% - 248px); min-width: 0; margin-left: 248px; padding: 30px 34px 34px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 23px;
}

.eyebrow { margin: 0 0 6px; color: #9b9fb0; font-size: 9px; font-weight: 700; letter-spacing: 1.1px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 700 23px 'Manrope', sans-serif; letter-spacing: -.7px; }
.topbar-actions { display: flex; align-items: center; gap: 15px; }
.demo-badge { padding: 7px 10px; border-radius: 20px; background: #fff8e9; color: #9b7131; font-size: 10px; font-weight: 600; }
.demo-badge span { margin-right: 4px; color: #e4a43b; font-size: 8px; }

.icon-button {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #888ea0;
  cursor: pointer;
  font-size: 17px;
}

.icon-button:hover { background: #f3f4f8; color: var(--ink); }
.help-button { border: 1px solid #e8eaf0; font-size: 12px; font-weight: 700; }
.back-button { display: none; }

.inbox {
  display: grid;
  height: calc(100vh - 121px);
  min-height: 540px;
  grid-template-columns: minmax(290px, 340px) minmax(400px, 1fr);
  overflow: hidden;
  border: 1px solid #e9ebf1;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 26px #252c4510;
}

.conversation-panel { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 19px 15px; }
.panel-heading h2, .thread-header h2 { margin: 0 0 4px; font: 700 15px 'Manrope', sans-serif; }
.subtle { color: var(--muted); font-size: 10px; }
.new-chat { background: var(--primary-soft); color: var(--primary); font-size: 20px; }

.search-box {
  display: flex;
  height: 37px;
  align-items: center;
  gap: 8px;
  margin: 0 16px 13px;
  padding: 0 9px;
  border: 1px solid #ebedf2;
  border-radius: 7px;
  color: #9298a9;
}

.search-box > span:first-child { font-size: 20px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-box input::placeholder { color: #a7abba; }
.search-box kbd { padding: 3px 4px; border: 1px solid #eceef2; border-radius: 4px; color: #a0a5b3; font: 9px 'DM Sans', sans-serif; white-space: nowrap; }

.filters { display: flex; gap: 4px; padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.filter { padding: 7px 8px; border: 0; border-radius: 6px; background: transparent; color: #818799; cursor: pointer; font-size: 10px; }
.filter span { margin-left: 3px; color: #a0a5b3; }
.filter.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.filter.active span { color: var(--primary); }

.conversation-list { flex: 1; overflow: auto; }
.conversation-item {
  display: flex;
  width: 100%;
  gap: 10px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #f1f2f5;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.conversation-item:hover { background: #fafaff; }
.conversation-item.selected { background: #f6f5ff; box-shadow: inset 3px 0 var(--primary); }
.conversation-copy { flex: 1; min-width: 0; }
.conversation-line { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.conversation-line strong { overflow: hidden; color: #34394b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-line time { flex: 0 0 auto; color: #a5a9b5; font-size: 9px; }
.conversation-preview { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }
.conversation-preview span:first-child { overflow: hidden; color: #9297a7; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--primary); }
.conversation-tags { display: flex; gap: 5px; margin-top: 8px; }
.tag { padding: 3px 6px; border-radius: 4px; background: #f2f3f7; color: #7b8191; font-size: 8px; }
.tag.purple { background: #f0efff; color: #655bd0; }
.tag.green { background: #eaf7f1; color: #429576; }
.list-empty { padding: 26px 18px; color: var(--muted); font-size: 11px; text-align: center; }

.thread-panel { position: relative; display: flex; min-width: 0; flex-direction: column; background: #fff; }
.thread { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.thread-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; padding: 12px 21px; border-bottom: 1px solid var(--line); }
.contact-summary { display: flex; align-items: center; gap: 10px; }
.contact-summary h2 { font-size: 12px; }
.thread-actions { display: flex; align-items: center; gap: 8px; }
.outline-button { padding: 7px 9px; border: 1px solid #e9ebf0; border-radius: 6px; background: #fff; color: #666d80; cursor: pointer; font-size: 9px; }
.outline-button:hover { border-color: #c9c5f8; color: var(--primary); }
.thread-meta { padding: 8px 15px; border-bottom: 1px solid #f0f1f5; color: #999eac; font-size: 9px; text-align: center; }
.messages { display: flex; flex: 1; flex-direction: column; gap: 12px; overflow: auto; padding: 20px 24px; background-color: #fbfcfe; background-image: radial-gradient(#eceef3 0.6px, transparent .6px); background-size: 17px 17px; }
.day-divider { align-self: center; padding: 5px 8px; border: 1px solid #eceef2; border-radius: 12px; background: #fff; color: #989dac; font-size: 9px; }
.message { display: flex; max-width: min(74%, 470px); flex-direction: column; gap: 5px; }
.message.incoming { align-self: flex-start; }
.message.outgoing { align-self: flex-end; }
.message-bubble { padding: 10px 12px; border: 1px solid #edf0f3; border-radius: 3px 11px 11px; background: #fff; color: #4a5061; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.outgoing .message-bubble { border-color: #e7e3ff; border-radius: 11px 3px 11px 11px; background: #efedff; }
.message time { padding: 0 3px; color: #a3a8b5; font-size: 8px; }
.outgoing time { text-align: right; }
.composer { padding: 12px 15px 14px; border-top: 1px solid var(--line); background: #fff; }
.composer textarea { display: block; width: 100%; min-height: 47px; max-height: 120px; resize: vertical; border: 0; outline: 0; color: var(--ink); font-size: 11px; line-height: 1.5; }
.composer textarea::placeholder { color: #a7abba; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 7px; }
.composer-note { color: #a3a8b5; font-size: 9px; }
.send-button { display: flex; align-items: center; gap: 12px; padding: 8px 11px; border: 0; border-radius: 6px; background: var(--primary); color: #fff; cursor: pointer; font-size: 10px; font-weight: 600; }
.send-button:hover { background: var(--primary-dark); }
.send-button span:last-child { font-size: 13px; }

.empty-state { display: flex; height: 100%; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.empty-illustration { position: relative; width: 124px; height: 92px; margin-bottom: 22px; }
.bubble { position: absolute; display: block; border: 1px solid #e6e5f7; border-radius: 12px; background: #f4f3ff; }
.bubble-one { top: 5px; left: 16px; width: 76px; height: 50px; transform: rotate(-7deg); }
.bubble-two { top: 27px; right: 8px; width: 71px; height: 48px; border-color: #dedafc; background: #e8e5ff; transform: rotate(7deg); }
.bubble-three { top: 40px; left: 20px; width: 66px; height: 42px; background: #fafaff; }
.empty-state h2 { margin: 0 0 7px; font: 700 15px 'Manrope', sans-serif; }
.empty-state p { margin: 0 0 14px; color: #8d93a3; font-size: 11px; }
.empty-hint { color: #aaaebb; font-size: 9px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; padding: 11px 15px; border-radius: 8px; background: #292d3d; color: #fff; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; font-size: 11px; }
.toast.visible { opacity: 1; transform: translateY(0); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 20%, #eeedff, transparent 38%), var(--canvas); }
.login-card { width: min(100%, 390px); padding: 34px; border: 1px solid #e9ebf1; border-radius: 14px; background: #fff; box-shadow: 0 12px 40px #252c4512; }
.login-brand { margin: 0 0 32px; }
.login-card h1 { margin: 0 0 9px; font-size: 21px; }
.login-card > p { margin: 0 0 24px; color: #8d93a3; font-size: 12px; line-height: 1.6; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 6px; color: #555b6d; font-size: 11px; font-weight: 600; }
.login-form input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #e6e8ef; border-radius: 7px; outline: 0; color: var(--ink); font-size: 12px; }
.login-form input:focus { border-color: #a7a1f0; box-shadow: 0 0 0 3px #6258d91c; }
.login-error { margin: 5px 0; color: #b54152; font-size: 11px; }
.login-submit { justify-content: center; min-height: 39px; margin-top: 12px; }
.send-button:disabled { cursor: wait; opacity: .65; }

@media (max-width: 1000px) {
  .sidebar { width: 206px; }
  .workspace { width: calc(100% - 206px); margin-left: 206px; padding-right: 20px; padding-left: 20px; }
  .inbox { grid-template-columns: minmax(260px, 310px) minmax(330px, 1fr); }
  .composer-note { max-width: 190px; line-height: 1.4; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: 62px; align-items: center; padding: 17px 8px; }
  .brand { margin: 0 0 38px; }
  .brand > span:last-child, .nav-item > span:not(.nav-icon), .connection-card, .profile-copy, .profile .icon-button { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .main-nav { width: 100%; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-icon { font-size: 19px; }
  .profile { justify-content: center; padding-top: 14px; }
  .workspace { width: calc(100% - 62px); margin-left: 0; padding: 20px 12px 12px; }
  .topbar { margin-bottom: 16px; }
  h1 { font-size: 19px; }
  .demo-badge { font-size: 0; }
  .demo-badge span { font-size: 8px; }
  .topbar-actions { gap: 7px; }
  .inbox { height: calc(100vh - 100px); min-height: 460px; grid-template-columns: minmax(0, 1fr); }
  .conversation-panel { border-right: 0; }
  .thread-panel { display: none; }
  .inbox.show-thread .conversation-panel { display: none; }
  .inbox.show-thread .thread-panel { display: flex; }
  .back-button { display: grid; }
  .conversation-item { padding: 13px 15px; }
  .thread-header { padding: 10px 12px; }
  .messages { padding: 17px 13px; }
}

@media (max-width: 420px) {
  .workspace { padding-right: 8px; padding-left: 8px; }
  .help-button { display: none; }
  .thread-actions .outline-button { padding: 7px 6px; font-size: 8px; }
  .composer-note { max-width: 150px; font-size: 8px; }
}

/* Conexões */
.connections-page { overflow-y: auto; padding-bottom: 24px; }
.connection-form { display: flex; gap: 8px; padding: 16px 24px; max-width: 560px; }
.connection-form input { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--surface); color: var(--ink); }
.connection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 0 24px; }
.connection-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.connection-item header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status-pill { font-size: 10px; padding: 3px 8px; border-radius: 99px; background: var(--canvas); color: var(--muted); }
.status-connected { background: #e3f6ee; color: var(--green); }
.status-qrcode, .status-connecting { background: var(--primary-soft); color: var(--primary); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.qr-box img { width: 220px; max-width: 100%; background: #fff; padding: 8px; border-radius: 8px; }
.connection-actions { display: flex; gap: 6px; }
.outline-button.danger:hover { border-color: #f3b4b4; color: #c94343; }
