/* ============================================================
 * ARVEN v2 — Polish + Mobile (rev 5 — padrão Renova 3-pane)
 * ============================================================ */

* { -webkit-tap-highlight-color: transparent; }

button, .conv-item, .team-row, .card-action, .btn-primary, .btn-ghost,
.role-pill, .pill, .toggle {
  transition: background .15s ease, color .15s ease, border-color .15s ease,
              transform .12s ease, opacity .15s ease;
}
button:active:not(:disabled) { transform: scale(.97); }

.modal-bg { animation: arven-fade-in .18s ease-out; }
.modal { animation: arven-pop-in .22s cubic-bezier(.16,1,.3,1); }
@keyframes arven-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes arven-pop-in {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.20); }

/* View Transitions API */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: none; opacity: 1; }
::view-transition-new(root) { animation: arven-vt-in .18s cubic-bezier(.4,0,.2,1); }
@keyframes arven-vt-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
aside.sidebar, #sidebar-slot, .mobile-top-bar {
  view-transition-name: arven-nav;
}
::view-transition-old(arven-nav),
::view-transition-new(arven-nav) {
  animation: none !important;
}

/* Background sólido */
html, body { background: #0a0c12 !important; }
html { color-scheme: dark; }
.main, .app { background: #0a0c12; min-height: 100vh; }

/* Mobile top bar (escondida no desktop) */
.mobile-top-bar { display: none !important; }

/* ============================================================
 * MOBILE — <= 768px
 * ============================================================ */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  .app { display: block !important; min-height: 100vh; }

  /* ===== HEADER TOP fixo: logo + nome + avatar ===== */
  .mobile-top-bar {
    display: flex !important;
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 100;
    align-items: center; justify-content: space-between;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0));
    background: rgba(12,14,22,0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .mobile-top-bar .mtb-brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: #fff;
  }
  .mobile-top-bar .mtb-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #3edcc0, #2db096);
    display: grid; place-items: center;
    color: #0c0e16; font-weight: 800; font-size: 13px;
    overflow: hidden; text-decoration: none;
    border: 2px solid rgba(255,255,255,.10);
  }
  .page-brand { display: none !important; }

  /* ===== MAIN: padding pra não ficar atrás do header/nav ===== */
  .main {
    padding: calc(72px + env(safe-area-inset-top, 0)) 14px calc(88px + env(safe-area-inset-bottom, 0)) !important;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  /* ===== SIDEBAR como bottom nav ===== */
  #sidebar-slot, aside.sidebar {
    position: fixed !important;
    bottom: 0; left: 0; right: 0;
    z-index: 95;
    width: 100% !important; height: auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-around !important;
    gap: 0 !important;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0)) !important;
    margin: 0 !important;
    background: rgba(12,14,22,0.96) !important;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,.10) !important;
    border-right: 0 !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3) !important;
  }
  aside.sidebar .brand-mark,
  aside.sidebar .brand-name,
  aside.sidebar .nav-spacer { display: none !important; }
  aside.sidebar .nav-item {
    flex: 1 1 0; min-width: 0;
    width: auto !important; height: auto !important;
    padding: 8px 4px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important; justify-content: center !important;
    border-radius: 10px !important;
    color: rgba(255,255,255,.55) !important;
    background: transparent !important;
    box-shadow: none !important;
    position: relative;
  }
  aside.sidebar .nav-item svg {
    width: 22px !important; height: 22px !important;
    margin: 0 !important; flex-shrink: 0;
  }
  aside.sidebar .nav-item:hover,
  aside.sidebar .nav-item.active {
    color: #3edcc0 !important;
    background: rgba(62,220,192,.10) !important;
  }
  aside.sidebar .nav-item .badge {
    position: absolute;
    top: 2px; right: 18%;
    min-width: 14px; height: 14px;
    background: #ff5e7a;
    color: #fff; font-size: 9px; font-weight: 800;
    border-radius: 99px;
    display: grid; place-items: center;
    padding: 0 4px;
  }
  aside.sidebar .nav-item.logout { display: none !important; }

  /* ===== Páginas em geral: column ===== */
  .dash {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }
  .col-main, .col-right {
    width: 100% !important;
    max-width: 100% !important;
  }
  .lists {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  .page-h {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .page-h h1 { font-size: 22px !important; line-height: 1.15 !important; }
  .page-h .sub { font-size: 12px !important; }
  .page-h .actions {
    width: 100%;
    justify-content: flex-start !important;
    flex-wrap: wrap;
    gap: 6px !important;
  }
  .page-h .actions button {
    font-size: 11px !important;
    padding: 7px 11px !important;
    flex: 0 0 auto;
  }

  #gf-period, .seg {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #gf-period::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
  #gf-period button, .seg button {
    flex: 0 0 auto !important;
    white-space: nowrap;
  }

  .card { padding: 16px !important; border-radius: 14px !important; }
  .card h2 { font-size: 17px !important; }
  .card h3 { font-size: 14px !important; }
  .card-title { font-size: 14px !important; }
  .donut-card { padding: 16px !important; }
  .donut-wrap svg { max-width: 180px; }

  #funnel-card { overflow: hidden; }
  #funnel-stages { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  #funnel-stages > div:first-child,
  #funnel-stages > div:nth-child(2) { min-width: 640px; }

  #insights-row, #insights-row-2, #insights-row-3,
  #gasto-cards {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }

  /* ===== /CONVERSAS — simplificado: lista SEMPRE visível, chat/info overlay ===== */
  body.is-conversas .conv-layout,
  body.is-conversas .conv-shell {
    display: block !important;
    grid-template-columns: none !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 0 !important;
  }

  /* LISTA — SEMPRE visível em mobile, sem condição */
  body.is-conversas .conv-list-card {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: calc(100vh - 200px) !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  /* CHAT — overlay fullscreen. OVERRIDE explícito do transform/top/bottom legado de style.css */
  body.is-conversas .chat-card {
    display: none !important;
    transform: translateX(100%) !important;
  }
  body.is-conversas.show-chat .chat-card {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    /* 100dvh evita a barra do browser iOS cortar o footer */
    height: 100dvh !important;
    max-height: 100dvh !important;
    transform: translateX(0) !important;
    z-index: 9000 !important;
    background: #0a0c12 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }
  /* chat-foot precisa aparecer no mobile — sempre visível na base + interativo */
  body.is-conversas.show-chat .chat-foot {
    display: flex !important;
    flex-shrink: 0 !important;
    padding: 10px 12px !important;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
    background: rgba(20,22,32,.98) !important;
    gap: 8px !important;
    align-items: center !important;
    border-top: 1px solid rgba(255,255,255,.08);
    pointer-events: auto !important;
    z-index: 9100 !important;
    position: relative;
  }
  body.is-conversas.show-chat .chat-foot * {
    pointer-events: auto !important;
    -webkit-user-select: auto;
    user-select: auto;
    touch-action: manipulation;
  }
  body.is-conversas.show-chat .chat-foot .pause-toggle {
    padding: 8px 12px !important;
    font-size: 11px !important;
    flex-shrink: 0;
    cursor: pointer;
    min-height: 40px;
  }
  body.is-conversas.show-chat .chat-foot input {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    font-size: 16px !important; /* previne zoom automatico iOS ao focar */
    padding: 10px 14px !important;
    background: rgba(255,255,255,.06) !important;
    border-radius: 20px !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,.08) !important;
  }
  body.is-conversas.show-chat .chat-foot .send-btn {
    width: 40px !important; height: 40px !important;
    flex-shrink: 0;
    cursor: pointer;
  }
  body.is-conversas.show-chat .chat-body {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }
  body.is-conversas.show-chat .mobile-top-bar,
  body.is-conversas.show-chat .page-h,
  body.is-conversas.show-chat #sidebar-slot,
  body.is-conversas.show-chat .conv-list-card,
  body.is-conversas.show-chat #page-help-footer { display: none !important; }

  /* INFO — overlay fullscreen (override display:none legado de style.css) */
  body.is-conversas .client-card {
    display: none !important;
  }
  body.is-conversas.show-info .client-card {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important;
    z-index: 9500 !important;
    background: #0a0c12 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: none !important;
  }
  body.is-conversas.show-info .mobile-top-bar,
  body.is-conversas.show-info .page-h,
  body.is-conversas.show-info #sidebar-slot { display: none !important; }

  /* Header da lista */
  body.is-conversas .conv-list-head {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(10,12,18,0.96);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    margin: 0 -14px !important;
    padding: 12px 14px 10px !important;
  }
  body.is-conversas .conv-list-head h2 { display: none !important; }
  body.is-conversas .conv-list-head .conv-search { margin-bottom: 10px !important; }
  body.is-conversas .conv-list-head .conv-search input {
    height: 40px;
    font-size: 14px !important;
  }
  body.is-conversas .conv-list-head > div[style*="Status conversa"],
  body.is-conversas .conv-list-head > div[style*="Status entrega"] { display: none !important; }
  body.is-conversas #conv-filter {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 8px !important;
  }
  body.is-conversas #conv-filter::-webkit-scrollbar { display: none; }
  body.is-conversas #conv-filter .cf-chip {
    flex: 0 0 auto !important;
    font-size: 12px !important;
    padding: 7px 12px !important;
  }
  body.is-conversas .conv-list-head > div:nth-of-type(4) {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none;
    border-bottom: 0 !important;
    padding-bottom: 4px !important;
    margin-bottom: 8px !important;
  }
  body.is-conversas .conv-list-head > div:nth-of-type(4)::-webkit-scrollbar { display: none; }
  /* Esconde filtros extras (produto/pacote/data) — pra simplicidade WhatsApp */
  body.is-conversas .conv-list-head > div[style*="grid-template-columns:1fr 1fr"],
  body.is-conversas .conv-list-head #conv-date-filter { display: none !important; }

  /* LISTA de conversas WhatsApp-style */
  body.is-conversas .conv-list, body.is-conversas #conv-list {
    display: block !important;
    flex: 1 !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 -14px !important;
  }
  body.is-conversas #conv-list .conv-item {
    display: grid !important;
    grid-template-columns: 56px 1fr auto !important;
    gap: 12px !important;
    padding: 14px 16px !important;
    background: transparent !important;
    border-bottom: 1px solid rgba(255,255,255,.05) !important;
    border-radius: 0 !important;
    transition: background .12s;
    cursor: pointer;
  }
  body.is-conversas #conv-list .conv-item:active {
    background: rgba(255,255,255,.04) !important;
  }
  body.is-conversas #conv-list .conv-item .av {
    width: 52px !important; height: 52px !important;
    border-radius: 50% !important;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
  }
  body.is-conversas #conv-list .conv-item .av img.av-img {
    width: 100%; height: 100%;
    object-fit: cover; border-radius: 50%;
    position: absolute; inset: 0; z-index: 2;
    background: transparent;
  }
  /* v2: iniciais SEMPRE visíveis por baixo (fallback base). Img cobre por cima quando carrega.
     Se img falhar, .av-fallback esconde e iniciais ficam visíveis sem flash. */
  .av .av-init {
    display: grid; place-items: center;
    position: absolute; inset: 0; z-index: 1;
    font-size: 15px; font-weight: 700; color: rgba(255,255,255,.65);
    letter-spacing: -.02em;
  }
  .av.av-fallback .av-img { display: none !important; }
  body.is-conversas #conv-list .conv-item .ci-body {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 4px;
    min-width: 0; overflow: hidden;
  }
  body.is-conversas #conv-list .conv-item .ci-name {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #fff !important;
    display: flex !important;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.is-conversas #conv-list .conv-item .ci-name > span:first-child {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.is-conversas #conv-list .conv-item .ci-name .pmini {
    flex-shrink: 0;
    font-size: 9.5px !important;
    padding: 2px 6px !important;
    border-radius: 99px;
  }
  body.is-conversas #conv-list .conv-item .ci-last {
    font-size: 13.5px !important;
    color: rgba(255,255,255,.55) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.is-conversas #conv-list .conv-item.unread .ci-name { color: #fff !important; font-weight: 700 !important; }
  body.is-conversas #conv-list .conv-item.unread .ci-last { color: rgba(255,255,255,.85) !important; }
  body.is-conversas #conv-list .conv-item .ci-right {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 6px;
    font-size: 11.5px !important;
    color: rgba(255,255,255,.45) !important;
    flex-shrink: 0;
  }
  body.is-conversas #conv-list .conv-item.unread .ci-right { color: #3edcc0 !important; }
  body.is-conversas #conv-list .conv-item .ci-unread {
    background: #3edcc0;
    color: #0c0e16;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 99px;
    min-width: 22px;
    text-align: center;
  }
  body.is-conversas #conv-list .empty {
    padding: 60px 20px !important;
    text-align: center;
    color: rgba(255,255,255,.45);
    font-size: 13px;
  }

  /* CHAT pane fullscreen */
  body.show-chat .chat-card .chat-head {
    background: rgba(20,22,32,.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    padding: 10px 14px !important;
    padding-top: calc(10px + env(safe-area-inset-top, 0)) !important;
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky; top: 0; z-index: 5;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
  }
  body.show-chat .chat-card .chat-head::before {
    content: "←";
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    padding: 0 8px 0 0;
    line-height: 1;
    flex-shrink: 0;
  }
  body.show-chat .chat-card .chat-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 14px !important;
    display: flex; flex-direction: column; gap: 6px;
  }
  body.show-chat .chat-card .chat-foot {
    position: sticky; bottom: 0;
    background: rgba(20,22,32,.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 10px 14px !important;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
  }

  /* CLIENT INFO pane fullscreen — header com back */
  body.show-info .client-card::before {
    content: "← Voltar pra conversa";
    display: block;
    position: sticky; top: 0;
    background: rgba(20,22,32,.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0));
    color: #3edcc0;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    z-index: 5;
  }
  body.show-info .client-card .cc-head,
  body.show-info .client-card .cc-body {
    padding: 16px !important;
  }

  /* Page header de Conversas esconde sempre */
  body.is-conversas .page-h { display: none !important; }

  /* ===== Outras páginas mobile ===== */
  .cat-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .kanban {
    grid-template-columns: repeat(4, 85vw) !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 12px !important;
  }
  .kanban .col { scroll-snap-align: start; }

  /* Configurações */
  .cfg-shell, .cfg-layout {
    display: flex !important;
    flex-direction: column !important;
  }
  aside.cfg-side, .cfg-side {
    width: 100% !important;
    position: sticky !important;
    top: calc(56px + env(safe-area-inset-top, 0)) !important;
    z-index: 30;
    padding: 0 0 12px !important;
    margin: 0 -14px 14px !important;
    padding-left: 14px !important; padding-right: 14px !important;
    border-bottom: 1px solid rgba(255,255,255,.06);
    background: rgba(12,14,22,.92) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .cfg-side > div:not(:has(a)) { display: none !important; }
  .cfg-side a, .cfg-side nav a {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    padding: 8px 14px !important;
    margin-right: 6px !important;
    border-radius: 99px !important;
    font-size: 12px !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap;
    background: rgba(255,255,255,.04);
  }
  .cfg-side a svg, .cfg-side nav a svg {
    width: 14px !important; height: 14px !important;
  }
  .cfg-side a.on, .cfg-side a:hover {
    background: rgba(62,220,192,.18) !important;
    color: #3edcc0 !important;
  }
  aside.cfg-side > nav,
  aside.cfg-side > div,
  .cfg-side > nav {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    gap: 6px;
    padding: 12px 0 !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  aside.cfg-side > nav::-webkit-scrollbar { display: none; }

  .cfg-card, .card.cfg-card {
    padding: 18px !important;
    margin-bottom: 14px !important;
  }
  .cfg-card h2 { font-size: 16px !important; }
  .cfg-card .sub { font-size: 11.5px !important; margin-bottom: 14px !important; }
  .cfg-content { width: 100% !important; padding: 0 !important; }
  .field {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 12px 0 !important;
  }
  .field .l { font-size: 12px !important; width: 100% !important; }
  .field input, .field select, .field textarea { width: 100% !important; }

  #perfil > div {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  #perfil > div > div:first-child {
    align-self: center !important;
    margin-bottom: 14px;
  }
  #perfil > div > div:last-child {
    grid-template-columns: 1fr !important;
    width: 100%;
  }

  .team-row, .secret-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 14px !important;
  }

  /* Modais bottom-sheet */
  .modal-bg {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 22px 20px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: arven-slide-up .25s cubic-bezier(.16,1,.3,1) !important;
  }
  @keyframes arven-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  input, select, textarea, button { font-size: 16px !important; }
  input, select, textarea {
    min-height: 44px;
    padding: 10px 12px !important;
  }
  .btn-primary, .btn-ghost {
    min-height: 44px;
    padding: 10px 16px !important;
    font-size: 13px !important;
  }

  .toast, #toast {
    bottom: calc(80px + env(safe-area-inset-bottom, 0)) !important;
    left: 14px !important; right: 14px !important;
    width: auto !important;
    max-width: 100% !important;
  }

  .stats-row { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .stat { padding: 14px !important; }
  .stat .v { font-size: 22px !important; }

  .svc-toolbar, .clients-toolbar, .conv-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
}

/* ============================================================
 * TABLET — 769-1100
 * ============================================================ */
@media (min-width: 769px) and (max-width: 1100px) {
  .dash { grid-template-columns: 1fr !important; }
  .col-right { width: 100% !important; }
  .lists {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
  }
  #insights-row { grid-template-columns: 1fr 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================
 * CHAT MOBILE v3 — layout com position: absolute (imune ao bug
 * do Safari iOS com sticky bottom + 100dvh)
 *
 * chat-card = position:fixed fullscreen (backdrop preto)
 * chat-head = absolute top:0 (altura fixa 62px)
 * chat-body = absolute top:62px bottom:64px (área central rolável)
 * chat-foot = absolute bottom:0 (altura fixa 64px + safe-area)
 *
 * Sem flexbox pai, sem sticky, sem sombra de layout — 100% posicional.
 * ============================================================= */
body.show-chat .sidebar,
body.show-chat #sidebar-slot,
body.show-chat aside.sidebar {
  display: none !important;
}
body.show-chat .chat-card.chat-open,
body.show-chat.is-conversas .chat-card {
  display: block !important;
  position: fixed !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100vw !important;
  z-index: 9000 !important;
  background: #0a0c12 !important;
  transform: translateX(0) !important;
  border-radius: 0 !important;
  padding: 0 !important; margin: 0 !important;
  overflow: hidden !important;
}
body.show-chat .chat-card .chat-head {
  position: absolute !important;
  top: 0 !important; left: 0 !important; right: 0 !important;
  height: 62px !important;
  padding: 10px 14px !important;
  padding-top: calc(10px + env(safe-area-inset-top, 0)) !important;
  box-sizing: border-box !important;
  background: rgba(20,22,32,.98) !important;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  z-index: 3 !important;
}
body.show-chat .chat-card .chat-body {
  position: absolute !important;
  top: calc(62px + env(safe-area-inset-top, 0)) !important;
  bottom: calc(64px + env(safe-area-inset-bottom, 0)) !important;
  left: 0 !important; right: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding: 12px !important;
  z-index: 1 !important;
  padding: 12px !important;
}
body.show-chat .chat-card .chat-foot {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px 12px !important;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
  background: rgba(20,22,32,.98) !important;
  border-top: 1px solid rgba(255,255,255,.08) !important;
  /* v3: absolute em vez de sticky — Safari iOS respeita sempre */
  position: absolute !important;
  left: 0 !important; right: 0 !important; bottom: 0 !important;
  z-index: 4 !important;
  min-height: 64px !important;
  box-sizing: border-box !important;
}
body.show-chat .chat-card .chat-foot > * { pointer-events: auto !important; }
body.show-chat .chat-card .chat-foot .pause-toggle {
  flex-shrink: 0; padding: 8px 12px !important; font-size: 11px !important; min-height: 40px;
}
body.show-chat .chat-card .chat-foot input {
  flex: 1 1 auto !important; min-width: 0 !important; min-height: 40px !important;
  font-size: 16px !important; /* evita zoom automatico iOS */
  padding: 10px 14px !important;
  background: rgba(255,255,255,.06) !important;
  border-radius: 20px !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.08) !important;
}
body.show-chat .chat-card .chat-foot .send-btn {
  flex-shrink: 0; width: 40px !important; height: 40px !important;
}

/* ============================================================
   OVERRIDE HAMMER: garantir que chat-foot mobile é sempre visível
   Independente de outras regras (@media, .chat-open, etc)
   ============================================================ */
html body.show-chat .chat-card .chat-foot,
html body.show-chat.is-conversas .chat-card .chat-foot {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  min-height: 60px !important;
  transform: none !important;
  pointer-events: auto !important;
}
html body.show-chat .chat-card .chat-foot #msg-input,
html body.show-chat .chat-card .chat-foot #pause-toggle,
html body.show-chat .chat-card .chat-foot #send-btn {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* =============================================================
 * CHAT MESSAGES — layout coeso (v2)
 * ============================================================= */
.chat-body { display: flex; flex-direction: column; gap: 6px; }
.chat-body .chat-day {
  align-self: center;
  font-size: 11px; color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.05);
  padding: 4px 12px; border-radius: 99px;
  margin: 8px 0;
}
.chat-body .msg {
  max-width: 76%;
  padding: 8px 12px 6px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
}
.chat-body .msg.in { align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-body .msg.out {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg,#3edcc0,#2db096) !important;
  color: #0c0e16 !important;
}
.chat-body .msg .t {
  display: block; text-align: right;
  font-size: 10px; margin-top: 3px;
  color: rgba(255,255,255,.5);
}
.chat-body .msg.out .t { color: rgba(12,14,22,.55) !important; }

/* Audio */
.chat-body .msg.msg-audio {
  padding: 8px 10px 6px;
  min-width: 220px;
  max-width: 300px;
}
.chat-body .msg.msg-audio audio {
  width: 100%; height: 38px; border-radius: 6px;
  filter: hue-rotate(160deg);
}
.chat-body .msg-transcricao {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(0,0,0,.15);
  border-radius: 8px;
  border-left: 2px solid #3edcc0;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255,255,255,.9);
  display: flex; flex-direction: column; gap: 2px;
}
.chat-body .msg.out .msg-transcricao { background: rgba(12,14,22,.15); color: rgba(12,14,22,.85); border-left-color: rgba(12,14,22,.4); }
.chat-body .msg-transcricao strong {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #3edcc0;
}
.chat-body .msg.out .msg-transcricao strong { color: rgba(12,14,22,.7); }

/* Video / document / image */
.chat-body .msg.msg-video, .chat-body .msg.msg-doc {
  padding: 8px; max-width: 300px;
}
.chat-body .msg .msg-caption {
  margin-top: 6px; padding: 0 4px;
  font-size: 12.5px; color: rgba(255,255,255,.85); line-height: 1.4;
}
.chat-body .msg.out .msg-caption { color: rgba(12,14,22,.85); }

/* Mensagens em sequência do mesmo lado: colapsa o padding */
.chat-body .msg.in + .msg.in,
.chat-body .msg.out + .msg.out { margin-top: -2px; }
