/* Estilos próprios da tela (antes inline no HTML) */
  body { height: 100vh; overflow: hidden; }
  #login { min-height: 100vh; }
  #app { display: none; height: 100vh; grid-template-columns: 72px 360px minmax(0, 1fr); }

  /* Trilho lateral */
  .rail { background: var(--sidebar); display: flex; flex-direction: column; align-items: center; padding: 16px 0; gap: 14px; }
  .rail .logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #22c58f, #0d9467); color: #fff; box-shadow: 0 6px 18px rgba(13,148,103,.35); }
  .rail .logo svg { width: 21px; height: 21px; }
  .rail .spacer { flex: 1; }
  .rail .av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--sidebar-2); color: #9be7c6; font-weight: 700; font-size: 13px; border: 1px solid rgba(255,255,255,.1); }
  .rail button { all: unset; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--sidebar-text); cursor: pointer; }
  .rail button:hover { background: rgba(255,255,255,.07); color: #fff; }
  .rail button svg { width: 19px; height: 19px; }

  /* Lista de conversas */
  .listpane { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
  .lp-head { padding: 18px 18px 12px; }
  .lp-head h1 { font-size: 19px; }
  .lp-head small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .listpane { min-width: 0; }
  #list { min-width: 0; }
  .conv { min-width: 0; }
  /* Abas quebram linha quando não cabem (nada escondido ou cortado) */
  .tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 14px; border-bottom: 1px solid var(--border); }
  .tabs button { box-shadow: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--text-2); }
  .tabs button.on { background: var(--text); border-color: var(--text); color: var(--surface); }
  #list { overflow-y: auto; flex: 1; padding: 6px; }
  .conv { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 10px; cursor: pointer; transition: background .12s; }
  .conv:hover { background: var(--surface-2); }
  .conv.sel { background: var(--accent-soft); }
  .conv .av, .chat-av { width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
  .conv.sel .av { background: var(--accent); color: var(--accent-text); }
  .conv .ci { flex: 1; min-width: 0; display: grid; gap: 3px; }
  .conv .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: nowrap; }
  .conv .name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .conv .when { color: var(--faint); font-size: 11.5px; flex: none; }
  .conv .last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .badge { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; flex: none; }
  .badge.WAITING { background: var(--warn-soft); color: var(--warn); }
  .badge.AGENT { background: var(--accent-soft); color: var(--accent-ink); }
  .badge.BOT { background: var(--info-soft); color: var(--info); }

  .wa-banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; margin-bottom: 18px;
    background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
  .wa-banner b { display: block; }
  .wa-banner span { color: var(--text-2); font-size: 13px; }
  .empty-list { display: grid; place-items: center; text-align: center; gap: 6px; padding: 48px 24px; color: var(--muted); }
  .empty-list svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 6px; }
  .empty-list b { color: var(--text-2); }
  .empty-list span { font-size: 13px; max-width: 240px; }

  /* Conversa */
  main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
  #empty { margin: auto; display: grid; place-items: center; gap: 10px; text-align: center; color: var(--muted); max-width: 320px; }
  #empty .big { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
  #empty .big svg { width: 34px; height: 34px; }
  #empty b { color: var(--text); font-size: 17px; }
  #chat { display: none; flex-direction: column; height: 100%; min-height: 0; }
  #chatHead { background: var(--surface); padding: 12px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: var(--shadow-sm); z-index: 1; }
  #chatHead .who { flex: 1 1 140px; min-width: 0; }
  #chatHead .who strong, #chatHead .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #chatHead .who strong { font-size: 15px; }
  #chatHead .who small { color: var(--muted); display: block; font-size: 12.5px; }
  #back { display: none; }
  #msgs { flex: 1; overflow-y: auto; padding: 20px 7%; display: flex; flex-direction: column; gap: 6px;
    background-image: radial-gradient(color-mix(in srgb, var(--text) 6%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
  .m { max-width: 68%; padding: 8px 11px 5px; border-radius: 12px; background: var(--bubble-in); color: var(--text); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px .5px rgba(0,0,0,.12); border-top-left-radius: 4px; font-size: 14px; }
  .m.out { background: var(--bubble-out); align-self: flex-end; border-top-left-radius: 12px; border-top-right-radius: 4px; }
  .m .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 3px; display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
  .m .meta span:first-child { font-weight: 600; }
  .m .opts { margin: 8px -11px -5px; display: flex; flex-direction: column; border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent); }
  .m .opts span { text-align: center; padding: 7px; color: var(--info); font-size: 13px; font-weight: 500; border-bottom: 1px solid color-mix(in srgb, var(--text) 7%, transparent); }
  .m .opts span:last-child { border-bottom: 0; }
  .m img { max-width: 280px; border-radius: 8px; display: block; }
  .m a { color: var(--info); font-weight: 500; }
  .m.failed { box-shadow: 0 0 0 1.5px var(--danger); }
  .note { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); padding: 4px 12px; border-radius: 8px; box-shadow: var(--shadow-sm); }
  #banner { padding: 10px 20px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 500; display: none; border-bottom: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
  #composer { display: flex; gap: 10px; padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border); align-items: flex-end; }
  #composer textarea { flex: 1; resize: none; max-height: 160px; min-height: 44px; border-radius: 22px; padding: 11px 16px; background: var(--surface-2); }
  #attach { border-radius: 50%; width: 44px; height: 44px; padding: 0; }
  #sendBtn { border-radius: 22px; height: 44px; padding: 0 18px; }

  /* Tela média: chat mais estreito, botões do cabeçalho só com ícone */
  @media (max-width: 1280px) {
    #app { grid-template-columns: 64px 320px minmax(0, 1fr); }
    #chatHead .lbl { display: none; }
    #chatHead button { padding: 9px 11px; }
  }
  @media (max-width: 900px) {
    #app { grid-template-columns: 1fr; }
    #sendBtn .lbl { display: none; }
    #sendBtn { width: 44px; padding: 0; border-radius: 50%; }
    .rail { display: none !important; }
    #app.open .listpane { display: none; }
    #app:not(.open) main { display: none; }
    #back { display: inline-flex; }
    .m { max-width: 88%; }
    #msgs { padding: 14px; }
    #chatHead { padding: 10px 12px; }
    #composer { padding: 10px 12px; }
  }
  .rail .railbtn { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--sidebar-text); }
  .rail .railbtn:hover { background: rgba(255,255,255,.07); color: #fff; }
  .rail .railbtn svg { width: 19px; height: 19px; }
.login-help { text-align: center; margin-top: 8px; }
