﻿:root {
  color-scheme: dark;
  --chat-bg: #0b141a;
  --chat-panel: rgba(17, 27, 33, 0.95);
  --header-bg: #202c33;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --incoming: #202c33;
  --outgoing: #005c4b;
  --accent: #25d366;
  --chip-bg: #1f2c33;
  --shell-padding: clamp(16px, 2.5vw, 28px);
  --shell-padding-mobile: clamp(8px, 3vw, 12px);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

.form-field {
  width: 100%;
  margin: 8px 0;
}

.search-input.full {
  width: 100%;
}

.btn-full {
  width: 100%;
  margin-top: 12px;
  display: block;
}

.actions-row.secondary {
  justify-content: flex-start;
  padding: 4px 0;
  gap: 12px;
}

.input-label {
  display: block;
  color: #cbd5f5;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.select-full {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  font-size: 1rem;
}

.select-full:focus {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: 'Roboto', sans-serif;
  background: radial-gradient(circle at top, #233138, #111b21 60%);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}
body[data-page="mensagem"] { overflow: hidden; }
html, body { width: 100%; height: 100%; }
.device-page, .device-page body {
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

.device {
  background: var(--chat-panel);
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  overflow: hidden;
  position: relative;
  padding-bottom: 0;
}

@supports (height: 100dvh) { .device { height: 100dvh; } }

body[data-page="mensagem"] .page-content { min-height: 0; }
body[data-page="mensagem"] .device {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 0;
}
body[data-page="mensagem"] .app-shell {
  overflow: hidden;
}
body[data-page="mensagem"] .page-content { gap: 6px; }
body[data-page="mensagem"] .footer-actions {
  margin-top: 0;
  padding-top: 2px;
}
body[data-page="mensagem"] .footer-actions {
  position: static;
  padding: 4px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  background: none;
  backdrop-filter: none;
}
@media (max-width: 720px) {
  body[data-page="mensagem"].app-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  body[data-page="mensagem"] .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 16px;
    padding: var(--shell-padding-mobile);
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    overflow: hidden;
  }
  body[data-page="mensagem"] .page-content {
    gap: 6px;
    min-height: 0;
    overflow: hidden;
  }
  body[data-page="mensagem"] .page-content > .device {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body[data-page="mensagem"] .device {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body[data-page="mensagem"] .composer {
    transform: none;
  }
  body[data-page="mensagem"] .footer-actions {
    padding-top: 0;
  }
}

body[data-page="agendamento"] .page-content {
  min-height: 0;
}

@media (max-width: 720px) {
  body[data-page="agendamento"].app-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  body[data-page="agendamento"] .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 16px;
    padding: var(--shell-padding-mobile);
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    overflow: hidden;
  }

  body[data-page="agendamento"] .page-content {
    min-height: 0;
    overflow: auto;
    gap: 12px;
  }

  body[data-page="agendamento"] .footer-actions {
    position: static;
    margin-top: 0;
    padding: 4px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    background: none;
    backdrop-filter: none;
  }
}

.chat-header { background: var(--header-bg); padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.chat-header button { border: none; background: none; color: #d1d7db; font-size: 1.2rem; cursor: pointer; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #36af80, #1f7760); display: grid; place-items: center; font-weight: 600; }
.contact-info { flex: 1; }
.contact-info h1 { font-size: 1rem; margin: 0; }
.contact-info span { font-size: 0.82rem; color: var(--text-secondary); }
.header-actions { display: flex; gap: 18px; font-size: 1.1rem; color: #aebac1; }

.chat-body {
  flex: 1;
  background-color: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='340' height='340' viewBox='0 0 340 340'%3E%3Cdefs%3E%3CradialGradient id='g' cx='0.15' cy='0.15' r='1'%3E%3Cstop stop-color='%23162126'/%3E%3Cstop offset='1' stop-color='%230b141a'/%3E%3C/radialGradient%3E%3Cpattern id='p' width='170' height='170' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='15' cy='15' r='2' fill='%2327373d'/%3E%3Ccircle cx='95' cy='65' r='1.6' fill='%23222f34'/%3E%3Ccircle cx='150' cy='120' r='1.8' fill='%2327373d'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='340' height='340' fill='url(%23g)'/%3E%3Crect width='340' height='340' fill='url(%23p)' opacity='0.35'/%3E%3C/svg%3E");
  background-size: cover;
  padding: 20px 12px 76px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 600px) {
  .composer {
    padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px));
    align-items: center;
    transform: translateY(-24px);
  }
  .send-button { margin-bottom: 10px; }
  .chat-body { padding-bottom: calc(240px + env(safe-area-inset-bottom, 0px)); }
  .device { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 26px); }
}

.message { display: flex; flex-direction: column; gap: 4px; max-width: 100%; position: relative; }
.message p { margin: 0; line-height: 1.4; font-size: 0.92rem; word-break: break-word; }
.message.incoming { align-items: flex-start; }
.message.outgoing { align-items: flex-end; }
.message .message-action {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: #e9edef;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.message .message-action:hover {
  background: var(--accent);
  color: var(--chat-bg);
  transform: scale(1.05);
}
.message:hover .message-action,
.message.selected .message-action {
  opacity: 1;
  pointer-events: auto;
}
.message.selected .bubble {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

.bubble { padding: 10px 12px 6px; border-radius: 16px; position: relative; display: inline-block; background: var(--incoming); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); }
.message.outgoing .bubble { background: var(--outgoing); border-bottom-right-radius: 4px; }
.message.incoming .bubble { border-bottom-left-radius: 4px; }
.bubble.attachment { padding: 6px 8px; min-width: 220px; }
.bubble.attachment, .bubble.attachment-multi { width: min(420px, 88vw); }
.attachment-multi .attachment-meta { margin-top: 8px; }
.attachment-grid { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 6px; width: 100%; }
.attachment-grid-1 { grid-template-columns: 1fr; }
.attachment-grid figure { position: relative; padding-top: 70%; margin: 0; overflow: hidden; border-radius: 12px; background: #0f171c; }
.attachment-grid img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.attachment-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); color: #fff; font-weight: 700; font-size: 1.2rem; }

.timestamp { font-size: 0.7rem; color: #d1d7db; opacity: 0.8; margin-left: 8px; }

.composer { padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--header-bg); display: flex; align-items: center; gap: 8px; position: relative; box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.3); }
.composer button { border: none; background: none; color: #aebac1; font-size: 1.4rem; padding: 6px; cursor: pointer; }
.composer button:disabled { opacity: 0.4; cursor: not-allowed; }
.attachment-wrapper { position: relative; }
.attachment-menu { position: absolute; bottom: 58px; left: 0; width: min(360px, calc(100vw - 24px)); background: #233138; border-radius: 24px; padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; transform: translateY(10px); transform-origin: bottom left; z-index: 5; }
.attachment-menu.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.attachment-item { display: flex; align-items: center; gap: 12px; color: #e9edef; font-size: 0.9rem; padding: 4px 8px; border-radius: 16px; transition: background 0.2s ease; cursor: pointer; }
.attachment-item:hover { background: rgba(255, 255, 255, 0.04); }
.attachment-item .icon-circle { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; color: white; }
.icon-doc { background: linear-gradient(135deg, #c9419c, #89376e); }
.icon-camera { background: linear-gradient(135deg, #ff7d5d, #f0483d); }
.icon-gallery { background: linear-gradient(135deg, #35b5e9, #1c7cd6); }
.icon-audio { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.icon-location { background: linear-gradient(135deg, #4ade80, #22c55e); }
.icon-contact { background: linear-gradient(135deg, #60a5fa, #2563eb); }

.input-shell { flex: 1; background: #2a3942; border-radius: 18px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.pending-attachments { display: flex; flex-wrap: wrap; gap: 6px; max-height: 20vh; overflow-y: auto; padding-right: 4px; }
.pending-attachments::-webkit-scrollbar { width: 6px; }
.pending-attachments::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 999px; }
.pending-chip { display: flex; align-items: center; gap: 6px; background: var(--chip-bg); border-radius: 999px; padding: 4px 10px; font-size: 0.78rem; }
.pending-chip i { color: var(--accent); font-size: 0.85rem; line-height: 1; }
.pending-chip button { background: none; border: none; color: #b8c2c7; font-size: 0.8rem; padding: 0; cursor: pointer; }
.input-shell { min-width: 0; }
.input-area { flex: 1; min-height: 28px; max-height: 140px; overflow-y: auto; outline: none; border: none; color: var(--text-primary); font-size: 0.98rem; line-height: 1.4; padding-bottom: 2px; }
.input-area:empty::before { content: attr(data-placeholder); color: var(--text-secondary); }
.send-button { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: var(--chat-bg); font-size: 1.3rem; transition: background 0.2s ease; margin-right: 4px; margin-bottom: 0; }
.send-button:disabled { background: rgba(255, 255, 255, 0.08); color: #6c7a81; }

.emoji-panel { position: absolute; bottom: 84px; left: 8px; right: 8px; background: #1a2329; border-radius: 18px; padding: 12px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5); display: none; z-index: 10; border: 1px solid rgba(255, 255, 255, 0.05); }
.emoji-panel.visible { display: block; }
.emoji-panel-tabs { display: flex; gap: 8px; margin-bottom: 8px; justify-content: center; }
.emoji-panel-tabs button { border: none; background: transparent; color: #8696a0; width: 36px; height: 36px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; display: grid; place-items: center; }
.emoji-panel-tabs button.active { background: rgba(37, 211, 102, 0.15); color: var(--accent); }
.emoji-panel-tabs button:hover { background: rgba(255, 255, 255, 0.08); }
.emoji-panel-grid { display: grid; grid-template-columns: repeat(8, minmax(28px, 1fr)); gap: 6px; max-height: 260px; min-height: 220px; overflow-y: auto; padding: 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.emoji-cell { border: none; background: transparent; font-size: 1.3rem; cursor: pointer; padding: 4px; border-radius: 8px; transition: background 0.15s ease; }
.emoji-cell:hover { background: rgba(255, 255, 255, 0.08); }
.emoji-empty { grid-column: 1 / -1; text-align: center; color: var(--text-secondary); font-size: 0.85rem; margin: 12px 0 2px; }

.attachment-thumb { width: 200px; border-radius: 16px; margin-bottom: 8px; object-fit: cover; max-height: 220px; display: block; }
.attachment-caption { margin: 6px 2px 4px; color: var(--text-primary); font-size: 0.95rem; line-height: 1.35; word-break: break-word; }
.attachment-meta { display: flex; align-items: center; gap: 10px; }
.attachment-icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; }
.attachment-meta strong { display: block; font-size: 0.9rem; }
.attachment-meta span { font-size: 0.78rem; color: #c0cbcf; }

.status-bar { position: absolute; top: 0; left: 0; width: 100%; height: env(safe-area-inset-top, 0px); background: var(--header-bg); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; background: var(--header-bg); color: var(--text-primary); position: sticky; top: 0; z-index: 6; min-height: 56px; }
.topbar .top-actions { display: flex; gap: 8px; }
.topbar .back { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; color: inherit; font-weight: 600; cursor: pointer; }
.topbar-title { font-size: 0.95rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; }

/* App shared UI (login, dashboard, usuarios) */
.app-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  width: 100%;
}
.app-shell {
  flex: 1;
  width: min(1200px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--chat-panel);
  border-radius: 0;
  padding: var(--shell-padding);
  box-shadow: none;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border-radius: 18px;
  border: 1px solid rgba(11, 20, 26, 0.08);
  background: #ffffff;
  box-shadow: 0 14px 28px rgba(7, 10, 12, 0.18);
  color: #0b141a;
  width: 100%;
  margin: 0 0 18px;
}
.brand-logo {
  width: clamp(90px, 16vw, 150px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.25));
}
.brand-hero-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}
.brand-hero .app-title {
  color: #0b141a;
}
.brand-hero .app-subtitle {
  color: #4b5563;
  margin: 0;
}
.brand-hero.brand-hero-centered {
  flex-direction: column;
  text-align: center;
  padding: 20px;
}
.brand-hero.brand-hero-centered .brand-hero-text {
  align-items: center;
}
body[data-page="dashboard"] .brand-hero {
  margin-left: 0;
}
body[data-page="login"] .brand-hero {
  margin: 0 0 18px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: var(--shell-padding-mobile);
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
  }

  .topbar {
    padding: 10px 12px;
  }
  .brand-hero {
    flex-direction: column;
    text-align: center;
    padding: 16px;
  }
  .brand-hero-text {
    align-items: center;
  }
}
.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.footer-actions {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(17, 27, 33, 0) 0%, rgba(17, 27, 33, 0.85) 40%, var(--chat-panel) 100%);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.footer-actions .btn-full { margin-top: 0; }
.footer-actions .btn-full + .btn-full {
  margin-top: 10px;
}
.app-title { margin: 0 0 6px 0; font-size: 1.6rem; font-weight: 600; }
.app-subtitle { margin: 0 0 18px 0; color: var(--text-secondary); }
.page-header { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-heading { flex: 1; min-width: 0; }
.page-header-action { margin-left: auto; white-space: nowrap; }
@media (max-width: 960px) {
  .page-header { align-items: flex-end; gap: 10px; }
}
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; }
.status-row .status-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-action { margin-left: auto; white-space: nowrap; flex-shrink: 0; }
.actions-row { display: flex; flex-direction: column; gap: 12px; }
.btn { border: none; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--chat-bg); box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35); }
.btn-tonal { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.08); }
.btn-ghost { background: transparent; color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.08); }
.btn-status { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.08); }
.btn-status.connected { background: #1fa463; color: #0b141a; border-color: #1fa463; }
.btn-status.disconnected { background: #b45309; color: #0b141a; border-color: #b45309; }
.btn-danger { background: #ef4444; color: #0b141a; border: 1px solid #ef4444; box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: #f25f5f; border-color: #f25f5f; }
.btn .material-symbols-outlined { font-size: 20px; line-height: 1; }
.material-symbols-outlined { font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; }
.list-card { background: rgba(0,0,0,0.18); border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 12px; max-height: 340px; overflow-y: auto; }
.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.contact-item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px; }
.contact-item label { flex: 1; cursor: pointer; }
.contact-item small { color: var(--text-secondary); display: block; }
.form-grid { display: grid; gap: 12px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.92rem; color: var(--text-secondary); }
.field input, .field select { width: 100%; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(0, 0, 0, 0.2); border-radius: 10px; padding: 12px; color: var(--text-primary); font-size: 1rem; }
.status-text { min-height: 1.2em; font-size: 0.92rem; color: var(--text-secondary); }
.status-text.sucesso { color: #7ddaa3; }
.status-text.erro { color: #ff7d7d; }
.actions-row.horizontal { flex-direction: row; flex-wrap: wrap; align-items: center; }
.table-wrapper { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); text-align: left; }
.table th { color: var(--text-secondary); font-weight: 500; }
.search-input { flex: 1; min-width: 200px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(0, 0, 0, 0.2); border-radius: 10px; padding: 10px; color: var(--text-primary); }
.admin-only { display: none; }
.admin .admin-only { display: block; }

@media (min-width: 720px) {
  .app-body { padding: 12px; }
  .app-shell {
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    min-height: calc(100vh - 24px);
    min-height: calc(100dvh - 24px);
  }
}

@media (min-width: 960px) {
  .app-body { padding: 6px 12px; }
  .app-shell {
    padding: 6px 18px 10px;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  body { padding: 0; }
  .device { width: 100%; height: 100vh; border-radius: 0; }
  .chat-body { padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px)); }
  .emoji-panel { bottom: 92px; left: 4px; right: 4px; }
  .emoji-panel-grid { grid-template-columns: repeat(7, minmax(28px, 1fr)); }
  .status-row { gap: 8px; }
  .status-action { padding: 10px 12px; }
}

/* Ajustes apenas para o mobile em envios */
@media (max-width: 720px) {
  body[data-page="envios"] .app-shell {
    gap: 12px;
  }

  body[data-page="envios"] .app-title {
    font-size: 1.35rem;
    margin-bottom: 2px;
  }

  body[data-page="envios"] .app-subtitle {
    font-size: 0.95rem;
    margin: 0 0 10px;
  }

  body[data-page="envios"] .actions-row.horizontal {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  body[data-page="envios"] .actions-row .btn {
    width: 100%;
  }

  body[data-page="envios"] .list-card {
    background: transparent;
    border: none;
    padding: 0;
    max-height: none;
  }

  body[data-page="envios"] .contact-list {
    gap: 12px;
  }

  body[data-page="envios"] .contact-item {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
    gap: 12px;
  }

  body[data-page="envios"] .contact-item label {
    width: 100%;
  }

  body[data-page="envios"] .contact-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1.05rem;
  }

  body[data-page="envios"] .contact-item small {
    display: block;
    line-height: 1.4;
  }

  body[data-page="envios"] .contact-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="envios"] .contact-actions .btn {
    width: 100%;
    justify-content: center;
  }

  body[data-page="envios"] .contact-actions .btn[data-editar-envio] {
    grid-column: 1 / -1;
  }
}

.tag-panel {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tag-panel-surface {
  background: rgba(15, 23, 42, 0.55);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  padding: 14px 16px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.tag-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: #e2e8f0;
}

.tag-panel-actions {
  display: inline-flex;
  gap: 6px;
}

.tag-panel-description {
  margin: 4px 0;
  color: #cbd5f5;
  font-size: 0.9rem;
}

.tag-panel-selected {
  font-size: 0.9rem;
  color: #e2e8f0;
  font-weight: 500;
}

.tag-refresh-btn {
  border: none;
  background: #eff3ff;
  color: #1d4ed8;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.tag-refresh-btn:hover {
  background: #dbeafe;
}

.tag-close-btn {
  border: none;
  background: rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.tag-close-btn:hover {
  background: rgba(148, 163, 184, 0.3);
}

.tag-select-control {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  gap: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  position: relative;
}

.mode-select-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.icon-toggle {
  width: 48px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.icon-toggle:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.icon-toggle.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}

.inline-search {
  margin-top: 8px;
}

.inline-search-fields {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-search-fields .search-input {
  width: 100%;
  min-width: 0;
}

.inline-search-fields .btn {
  padding: 10px 14px;
}

.mode-select-control {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  gap: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mode-select-control.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.mode-select-control.open {
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 0.9);
}

.mode-select-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mode-select-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.2);
  color: #38bdf8;
  font-size: 1.05rem;
}

.mode-select-text {
  font-size: 0.95rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-options {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.95);
  box-shadow: 0 25px 50px rgba(2, 6, 23, 0.4);
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 6px;
  z-index: 15;
  position: absolute;
  width: 100%;
  top: calc(100% + 6px);
  left: 0;
}
.mode-options[hidden] { display: none !important; }

.mode-option {
  border: none;
  background: transparent;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.mode-option:hover,
.mode-option.active {
  background: rgba(56, 189, 248, 0.15);
}

.mode-option-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.15);
  color: #38bdf8;
  font-size: 1rem;
  flex-shrink: 0;
}

.mode-option span {
  font-size: 0.92rem;
}

.tag-select-control.disabled,
.tag-select-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tag-select-control.open {
  border-color: #38bdf8;
  background: #1e293b;
}

.tag-select-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tag-select-text {
  font-size: 0.95rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
}

.tag-options {
  margin-top: 8px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 6px;
  z-index: 10;
}

.tag-option {
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.tag-option:hover,
.tag-option.active {
  background: #eef2ff;
}

.tag-option strong {
  font-size: 0.95rem;
  color: #0f172a;
}

.tag-option span {
  font-size: 0.8rem;
  color: #475569;
}

/* Mantem o painel de etiquetas dentro da coluna em telas grandes */
body[data-page="contatos"] #painelEtiquetas,
body[data-page="contatos"] #painelEtiquetas .tag-panel-surface,
body[data-page="contatos"] #painelEtiquetas .tag-options {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

body[data-page="contatos"] #painelEtiquetas .tag-options {
  overflow-x: hidden;
}

body[data-page="contatos"] #painelEtiquetas .tag-option strong {
  word-break: break-word;
}

@media (min-width: 960px) {
  /* Mantem o painel de etiquetas contido na coluna e com rolagem interna */
  body[data-page="contatos"] #painelEtiquetas {
    align-self: stretch;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
  }

  body[data-page="contatos"] #painelEtiquetas .tag-panel-surface {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body[data-page="contatos"] #painelEtiquetas .tag-options {
    flex: 1;
    max-height: none;
    overflow-y: auto;
  }
}

body[data-page="contatos"] .app-shell {
  height: 100vh;
  height: 100dvh;
}

body[data-page="contatos"] .page-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body[data-page="contatos"] .list-card {
  flex: 1;
  min-height: 0;
  max-height: none;
}

@media (min-width: 960px) {
  body[data-page="contatos"] .app-shell { gap: 12px; }
  body[data-page="contatos"] .page-content {
    display: grid;
    grid-template-columns: minmax(380px, 520px) 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "header header"
      "controls list"
      "tags list"
      "status list";
    gap: 12px 20px;
    align-items: start;
  }

  body[data-page="contatos"] .page-header { grid-area: header; margin-bottom: 2px; }
  body[data-page="contatos"] .form-field { grid-area: controls; margin: 0; }
  body[data-page="contatos"] #painelEtiquetas { grid-area: tags; margin: 0; }
  body[data-page="contatos"] .status-row {
    grid-area: status;
    justify-content: flex-end;
    gap: 12px;
  }
  body[data-page="contatos"] .status-row .status-text { text-align: right; }
  body[data-page="contatos"] .list-card {
    grid-area: list;
    height: 100%;
    min-height: 0;
    max-height: none;
    align-self: stretch;
  }

  /* Compacta cabeçalho e controles do painel de etiquetas para abrir espaço para a lista */
  body[data-page="contatos"] .tag-panel {
    margin: 6px 0 4px;
    gap: 8px;
  }

  body[data-page="contatos"] .tag-panel-surface {
    padding: 10px 12px;
  }

  body[data-page="contatos"] .tag-panel-header {
    margin-bottom: 6px;
    gap: 6px;
  }

  body[data-page="contatos"] .tag-panel-actions {
    gap: 4px;
  }

  body[data-page="contatos"] .tag-refresh-btn,
  body[data-page="contatos"] .tag-close-btn {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }

  body[data-page="contatos"] .tag-options {
    margin-top: 6px;
  }
}

@media (min-width: 1280px) {
  body[data-page="contatos"] .page-content {
    grid-template-columns: minmax(440px, 620px) 1fr;
    gap: 12px 24px;
  }
}

/* Indicador de passos (fluxo contatos > mensagem > agendamento) */
.steps-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  align-self: flex-end;
  margin-left: auto;
}

.steps-bar.right {
  margin-left: auto;
}

.step-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 6px 0;
}
.step-pill span:not(.step-number) { display: none; }

.step-pill::before,
.step-pill::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 2px;
  background: rgba(148, 163, 184, 0.35);
}

.step-pill::before { left: -28px; }
.step-pill::after { right: -28px; }
.steps-bar .step-pill:first-child::before { display: none; }
.steps-bar .step-pill:last-child::after { display: none; }

.step-pill .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.6);
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
  box-shadow: 0 0 0 1px rgba(30, 41, 59, 0.8);
}

.step-pill.active .step-number {
  border-color: #38bdf8;
  background: linear-gradient(120deg, #2563eb, #38bdf8);
  color: #0b1120;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.step-pill.active {
  color: #e2e8f0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}

.modal-card {
  width: min(420px, 100%);
  background: rgba(17, 27, 33, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modal-pop 160ms ease;
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(37, 211, 102, 0.12);
  color: #4ade80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
}

.modal-icon.danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
}

.modal-title {
  margin: 0 0 6px;
}

.modal-text {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@keyframes modal-pop {
  0% { opacity: 0; transform: translateY(12px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
