:root {
  color-scheme: dark;
  --bg: #0b0814;
  --card: rgba(21,15,36,.72);
  --purple: #7c3aed;
  --accent: #9b5cff;
  --lilac: #cdb4ff;
  --green: #34d399;
  --amber: #fbbf24;
  --muted: #b1a7c3;
  --line: #35274e;
  font: 15px Inter, sans-serif;
  color: #f4efff;
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, .brand { font-family: "Space Grotesk", sans-serif; margin: 0 0 .75rem; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
p { line-height: 1.5; overflow-wrap: anywhere; }
a { color: var(--lilac); }
button, input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 9px; padding: .6rem .7rem; background: #1a112b; min-width: 0; }
button { cursor: pointer; }
button:hover, a:hover { border-color: var(--accent); }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--purple); border-color: var(--purple); color: white; font-weight: 700; }
textarea { resize: vertical; }
label { display: grid; gap: .35rem; }
small, .muted { color: var(--muted); }
.warning { color: var(--amber); }
.online { color: var(--green); }
.error { color: #fda4af; }
.panel, .approval, .lead-card, .lane, details { border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login form { width: min(100%, 380px); padding: 1.5rem; display: grid; gap: 1rem; }
.login p:empty { display: none; }
#app { display: grid; grid-template-columns: 190px minmax(0, 1fr); height: 100dvh; }
aside { padding: 1rem; border-right: 1px solid var(--line); background: #120b21; }
.brand { display: block; color: var(--lilac); font-size: 1.35rem; }
nav { display: grid; gap: .35rem; }
nav a { position: relative; display: flex; align-items: center; gap: .45rem; padding: .65rem .45rem; border-radius: 8px; text-decoration: none; }
nav a[aria-current] { background: #30204c; color: white; }
nav a span { font-size: 1.2rem; }
#badge, .unread { border-radius: 999px; padding: .1rem .4rem; background: var(--green); color: #06251c; }
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.top, .account, #summary, .section-head, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.top, .section-head { justify-content: space-between; }
.top { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
#summary { font-size: .85rem; color: var(--lilac); }
#email { overflow-wrap: anywhere; }
#notice { padding: .5rem 1rem; color: var(--amber); }
main { flex: 1; min-height: 0; overflow: auto; padding: .85rem; }
.screen { min-width: 0; }
.conversations { height: 100%; display: grid; grid-template-columns: minmax(210px, 32%) minmax(0, 1fr); overflow: hidden; }
.inbox, #chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.inbox { padding: .65rem; border-right: 1px solid var(--line); gap: .55rem; }
#lead-list, #messages { overflow: auto; }
.lead-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem; text-align: left; border-color: transparent; background: transparent; }
.lead-row[aria-pressed="true"] { background: #2a1a44; border-color: var(--line); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: .7rem; color: var(--lilac); }
#chat-header, #composer { padding: .65rem; display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
#chat-header { border-bottom: 1px solid var(--line); }
#chat-header .identity { flex: 1 1 125px; overflow-wrap: anywhere; }
#chat-header select { max-width: 100%; }
#messages { flex: 1; padding: .75rem; }
.messages-list { display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; }
.bubble { padding: .55rem .7rem; border-radius: 12px; background: #251a36; max-width: 86%; min-width: 0; }
.bubble.saida { align-self: flex-end; background: #482483; }
.bubble.nota { align-self: center; background: #2b2832; color: #ddd6e7; }
.bubble.delivery { background: #262331; color: var(--muted); }
.bubble.delivery.error { color: #fda4af; }
.bubble small { display: block; margin-top: .25rem; color: inherit; opacity: .85; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
#chat-approval { overflow: auto; max-height: 38%; }
#chat-approval .approval { margin: .3rem .65rem; }
#composer textarea { flex: 1; max-height: 25dvh; }
#board { display: flex; overflow-x: auto; gap: .65rem; padding-bottom: .65rem; }
.lane { flex: 0 0 240px; min-width: 0; padding: .65rem; }
.lead-card, .approval, details, .channel-card { padding: .75rem; margin-bottom: .55rem; overflow-wrap: anywhere; }
.lead-card { cursor: pointer; }
.lead-card h3, .lead-card p, .approval p { margin: 0 0 .45rem; }
.lead-card select { width: 100%; }
.lead-name { border: 0; padding: 0; background: transparent; text-align: left; overflow-wrap: anywhere; font-weight: 700; }
summary { cursor: pointer; }
#resolved { margin-top: .65rem; }
.qr { display: block; width: min(100%, 320px); height: auto; padding: .5rem; background: white; }
dialog { width: min(560px, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 1rem; border: 1px solid var(--line); border-radius: 12px; color: inherit; background: #151024; }
dialog::backdrop { background: #080510bb; }
dialog form, .fields { display: grid; gap: .65rem; }
.fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
.mobile-back { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 700px) {
  #app { display: flex; flex-direction: column; padding-bottom: calc(61px + env(safe-area-inset-bottom)); }
  .workspace { flex: 1; }
  aside { position: fixed; inset: auto 0 0; z-index: 2; border: 0; border-top: 1px solid var(--line); padding: .2rem .25rem env(safe-area-inset-bottom); }
  .brand { display: none; }
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .15rem; }
  nav a { flex-direction: column; justify-content: center; gap: .15rem; padding: .3rem .05rem; min-height: 54px; font-size: .72rem; }
  #badge { position: absolute; top: 1px; left: calc(50% + 9px); font-size: .68rem; }
  .top { padding: .4rem .6rem; gap: .25rem; }
  .account { font-size: .8rem; }
  main { padding: .4rem; }
  .conversations { grid-template-columns: minmax(0, 1fr); }
  .inbox { border: 0; }
  .conversations:not(.chat-open) #chat, .chat-open .inbox { display: none; }
  .mobile-back { display: inline-block; }
  .lane { flex-basis: 78vw; }
}
