:root {
  --brand: #2f6fe0;
  --brand-dark: #1c4fb8;
  --brand-light: #eaf2fd;
  --brand-bubble: #dceafd;
  --bot-bubble: #e6e2fb;
  --bot-accent: #6d4fd6;
  --navy: #0e1c30;
  --navy-2: #17304f;
  --navy-3: #21406b;
  --bg: #f2f5fa;
  --panel: #ffffff;
  --border: #e3e8f1;
  --text: #10192b;
  --text-muted: #8992a6;
  --text-soft: #53617a;
  --red: #dc2626;
  --amber: #d97706;
  --green: #16a34a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 25, 43, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 25, 43, 0.12);
  --shadow-panel: 0 1px 0 rgba(16, 25, 43, 0.04);
  --shadow-card: 0 1px 2px rgba(16, 25, 43, 0.05), 0 1px 1px rgba(16, 25, 43, 0.03);
  --shadow-card-hover: 0 6px 16px rgba(16, 25, 43, 0.1);
  --topbar-h: 64px;
  --card-tint: #f7f9fd;
}

* { box-sizing: border-box; }

/* ---------- Tela de login ---------- */
#login-screen {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Painel visual (esquerda) */
.login-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at 25% 15%, #1a2f4d 0%, var(--navy) 45%, #060d18 100%);
}
.login-visual-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(circle at 50% 45%, black 0%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 45%, black 0%, transparent 72%);
}
.login-visual-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  pointer-events: none;
}
.login-visual-glow-1 {
  width: 420px; height: 420px;
  top: -120px; left: -100px;
  background: radial-gradient(circle, rgba(47, 111, 224, 0.55) 0%, transparent 70%);
}
.login-visual-glow-2 {
  width: 360px; height: 360px;
  bottom: -140px; right: -80px;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.28) 0%, transparent 70%);
}
.login-visual-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}
.login-visual-logo {
  width: 72px; height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  margin-bottom: 22px;
}
.login-visual-logo img { width: 52px; height: 52px; object-fit: contain; }
.login-visual-content h2 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
}
.login-visual-tagline {
  margin: 0 0 30px;
  font-size: 14.5px;
  font-weight: 500;
  color: #9aabc9;
  line-height: 1.5;
}
.login-visual-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-visual-features li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: #cdd8ec;
}
.login-visual-features svg {
  flex-shrink: 0;
  width: 26px; height: 26px;
  padding: 5px;
  border-radius: 50%;
  background: rgba(94, 234, 212, 0.14);
  color: #5eead4;
  stroke-width: 2.4;
}

/* Lado do formulário (direita) */
.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 32px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border-radius: 18px;
  padding: 36px 32px 30px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-box-logo-mobile { display: none; }
.login-box h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
.login-sub { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); font-weight: 500; line-height: 1.4; }
.login-box label {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap > svg {
  position: absolute;
  left: 12px;
  width: 16px; height: 16px;
  color: var(--text-muted);
  stroke-width: 2;
  pointer-events: none;
}
.login-box input {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  padding: 11px 12px 11px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-tint);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-box input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(47,111,224,0.12);
}
#login-password { padding-right: 38px; }
.input-toggle {
  position: absolute;
  right: 8px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
}
.input-toggle:hover { background: var(--card-tint); color: var(--text-soft); }
.input-toggle svg { width: 16px; height: 16px; stroke-width: 2; }
.login-box .login-submit {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  font-size: 13.5px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  box-shadow: 0 8px 20px rgba(47, 111, 224, 0.3);
  transition: transform .12s ease, box-shadow .12s ease;
}
.login-box .login-submit:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(47, 111, 224, 0.38); }
.login-box .login-submit:active { transform: translateY(0); }
.login-remember-label { margin-top: -2px; font-size: 12.5px; font-weight: 500 !important; color: var(--text-muted); }
.login-error {
  width: 100%;
  color: var(--red);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  margin: 2px 0 0;
  text-align: center;
}

@media (max-width: 860px) {
  #login-screen { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-form-side { background: radial-gradient(circle at 30% 20%, #1a2f4d 0%, var(--navy) 45%, #060d18 100%); }
  .login-box-logo-mobile {
    display: block;
    width: 48px; height: 48px;
    object-fit: contain;
    margin: 0 auto 6px;
  }
  .login-box h1, .login-sub { text-align: center; }
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button { font-family: inherit; }

/* [hidden] some vezes perde pra regras de display mais específicas dos
   próprios componentes (ex: #app{display:flex}, #login-screen{display:flex}).
   Isso garante que o atributo hidden sempre vence, seja qual for o elemento. */
[hidden] { display: none !important; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.body-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 330px 1fr 300px;
}

/* ---------- Topbar (cabeçalho superior) ---------- */
.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  background: linear-gradient(90deg, var(--navy) 0%, #0d1c30 55%, var(--navy-2) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 16px;
  gap: 16px;
  box-shadow: 0 2px 10px rgba(6, 12, 22, 0.35);
  position: relative;
  z-index: 40;
}

.topbar-brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--navy-3) 0%, var(--navy) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 10px rgba(47, 111, 224, 0.4);
  flex-shrink: 0;
}
.brand-logo img { width: 29px; height: 29px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { color: white; font-weight: 800; font-size: 14.5px; letter-spacing: -0.01em; }
.brand-sub { color: #92a1bd; font-size: 11px; font-weight: 600; }

.topbar-search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0 14px;
  height: 36px;
  color: #b9c4da;
  transition: background .15s ease, border-color .15s ease;
}
.topbar-search:focus-within { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.28); }
.topbar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: white;
  font-family: inherit;
  font-size: 13px;
}
.topbar-search input::placeholder { color: #7f8cab; }
.topbar-search[hidden] { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.topbar-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: #9caac6;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.topbar-btn svg { width: 17px; height: 17px; }
.topbar-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; }

.wa-status-pill {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  cursor: pointer;
  color: #d7deec;
  font-size: 12px;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease;
}
.wa-status-pill:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.22); }
.wa-status-pill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}
.wa-status-pill .dot.connected { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.28); }
.wa-status-pill .dot.connecting { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,0.22); }

/* ---------- Sidebar (lista de chamados) ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: var(--shadow-panel);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  gap: 10px;
}
.sidebar-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-chip {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--card-tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.stat-chip b { font-weight: 800; }
.stat-chip.stat-open { color: var(--red); border-color: #fbd5d5; background: #fef2f2; }
.stat-chip.stat-open b { color: var(--red); }
.stat-chip.stat-progress { color: var(--amber); border-color: #fbe3b0; background: #fffbeb; }
.stat-chip.stat-progress b { color: var(--amber); }

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-soft);
  flex-shrink: 0;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn-icon:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand-dark); }
.btn-icon:active { transform: scale(0.94); }
.btn-icon svg { width: 15px; height: 15px; }

.tabs {
  display: flex;
  flex-wrap: nowrap; /* as 3 abas ficam sempre na mesma linha */
  gap: 3px;
  padding: 2px 10px 12px;
}
.tab {
  border: none;
  background: transparent;
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 700;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--brand-light); color: var(--brand-dark); }
.tab { position: relative; display: inline-flex; align-items: center; gap: 5px; }
/* Indicador de mensagens novas não abertas na aba */
.tab-unread {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--panel);
  animation: tabUnreadPulse 1.6s ease-in-out infinite;
}
@keyframes tabUnreadPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.ticket-list { overflow-y: auto; flex: 1; padding: 2px 10px 10px; display: flex; flex-direction: column; gap: 6px; }

.ticket-item {
  padding: 12px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--panel);
  box-shadow: var(--shadow-card);
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}
.ticket-item:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
.ticket-item.selected { background: var(--brand-light); border-color: #cfe0fa; box-shadow: var(--shadow-card-hover); }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 1px 3px rgba(16,25,43,0.15);
}
.avatar.lg { width: 60px; height: 60px; font-size: 20px; box-shadow: 0 4px 12px rgba(16,25,43,0.18); }

.ticket-item-body { min-width: 0; flex: 1; }
.ticket-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.ticket-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.ticket-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.ticket-preview-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 2px; }
.ticket-preview {
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* "✓" mostrado antes da prévia quando a última mensagem do chamado foi
   nossa (técnico/bot) — igual o WhatsApp mostra pra dar pra ver, sem abrir
   o chamado, se a bola está com a gente ou esperando o cliente responder. */
.ticket-sent-check {
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 3px;
}
.ticket-item.unread .ticket-sent-check { color: inherit; }
/* Chamado fixado (📌) — fica sempre no topo da lista (ordenado assim pelo
   backend) e ganha uma leve marcação visual pra se destacar mesmo sem focar
   no ícone: uma tarja âmbar à esquerda e um fundo levemente amarelado. */
.ticket-item.pinned {
  background: #fffdf5;
  border-left: 3px solid #d4a017;
  padding-left: 9px;
}
.ticket-item.pinned.selected { background: var(--brand-light); }
.ticket-pin-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.55;
  filter: grayscale(1);
  flex-shrink: 0;
}
.ticket-item:hover .ticket-pin-btn { opacity: 1; }
.ticket-pin-btn:hover { background: rgba(212, 160, 23, 0.15); }
.ticket-pin-btn.active { opacity: 1; filter: none; }
/* Chamado com mensagem não lida — nome e prévia ficam mais escuros/em
   negrito, igual o WhatsApp faz numa conversa não lida. */
.ticket-item.unread .ticket-name { color: var(--text); }
.ticket-item.unread .ticket-preview { color: var(--text); font-weight: 600; }
.ticket-item.unread .ticket-time { color: var(--green); font-weight: 700; }
.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ticket-protocol {
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
  font-weight: 700;
}

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 7px;
  border-radius: 20px;
  width: fit-content;
  margin-top: 3px;
}
.badge.aberto { background: #fee2e2; color: var(--red); }
.badge.em_atendimento { background: #fef3c7; color: var(--amber); }
.badge.fechado { background: #e5e7eb; color: var(--text-muted); }

.empty-hint { padding: 20px; color: var(--text-muted); font-size: 13px; }

/* ---------- Conversation (centro) ---------- */
.conversation {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 380px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-icon {
  width: 52px; height: 52px; color: var(--brand);
  margin-bottom: 10px;
  padding: 14px;
  background: var(--brand-light);
  border-radius: 18px;
  box-sizing: content-box;
}
.empty-state .hint { font-size: 12.5px; margin-top: 8px; }

.conv-header {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-panel);
}
.conv-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.conv-header h2 { font-size: 14.5px; margin: 0; font-weight: 700; }
.conv-header .meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.conv-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.conv-actions select {
  border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 6px 9px; font-size: 12.5px;
  font-family: inherit; background: white; transition: border-color .15s ease;
}
.conv-actions select:hover { border-color: var(--brand); }
/* Botão "Fixar" no cabeçalho da conversa — mesma ideia do 📌 na lista de
   chamados, só que aqui com texto ao lado (cabe mais espaço). */
.conv-pin-btn.active {
  background: #fff8e6;
  border-color: #d4a017;
  color: #8a6a0c;
}
.conv-pin-btn.active:hover { background: #fdedc4; }

.btn-ghost, .btn-primary, .btn-danger, .btn-success {
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius-sm);
  padding: 6.5px 13px;
  font-size: 12.5px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: var(--brand-dark);
  color: white;
  box-shadow: 0 2px 6px rgba(47,111,224,0.3);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 3px 10px rgba(47,111,224,0.4); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost:hover { background: var(--bg); border-color: #d3dae8; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: var(--red); }
/* "Finalizar atendimento" — fecha o chamado E avisa o cliente (diferente
   do "Encerrar" ao lado, que fecha por dentro sem mandar nada pelo
   WhatsApp). Verde porque é a forma "normal"/completa de terminar um
   atendimento, e o vermelho do Encerrar fica reservado pra ação mais
   direta/silenciosa. */
.btn-success { color: var(--green); border-color: #bbf0cf; }
.btn-success:hover { background: #f0fdf5; border-color: var(--green); }
.btn-success:active { transform: translateY(1px); }
.btn-success:disabled { opacity: 0.6; cursor: default; }

.conv-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 10px;
}
.date-divider span {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.msg-row { display: flex; flex-direction: column; margin-bottom: 8px; }
.msg-row.out { align-items: flex-end; }
.msg-row.in { align-items: flex-start; }

.msg-sender { font-size: 11px; font-weight: 700; margin-bottom: 2px; padding: 0 4px; color: var(--text-soft); }

/* Botões de responder/apagar/editar — sempre visíveis ao lado do balão
   (ficavam só no hover antes, mas sumiam rápido demais e dificultava
   clicar). Posicionado relativo ao próprio balão (.msg, não .msg-row),
   senão "100%" seria a largura da linha inteira (que ocupa o conv-body
   todo) em vez da largura do balão. */
.msg-actions {
  position: absolute;
  top: 0;
  right: calc(100% + 4px);
  display: flex;
  gap: 2px;
  opacity: 1;
  pointer-events: auto;
}
/* Mensagem recebida (do cliente) fica encostada na borda esquerda — as
   ações apareceriam cortadas fora da tela se ficassem à esquerda do balão
   como nas mensagens nossas, então nesse caso ficam à direita dele. */
.msg-row.in .msg-actions { right: auto; left: calc(100% + 4px); }
.msg-actions button {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.msg-actions button:hover { background: var(--brand-light); color: var(--brand-dark); border-color: var(--brand); }
.msg-actions .msg-action-delete:hover { background: #fef2f2; color: var(--red); border-color: var(--red); }
.msg-actions .msg-action-reply:hover { background: var(--brand-light); color: var(--brand-dark); border-color: var(--brand); }

/* Trecho citado em cima do balão quando a mensagem é uma resposta a outra
   (feature "Responder") — igual o resuminho que o próprio WhatsApp mostra. */
.msg-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(16, 25, 43, 0.06);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  max-width: 100%;
}
.msg-quote-sender { font-weight: 700; color: var(--brand-dark); }
.msg-quote-text {
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg.nota .msg-quote { background: rgba(0, 0, 0, 0.05); border-left-color: #c7a92a; }
.msg.nota .msg-quote-sender { color: #8a7412; }

.msg.deleted { opacity: 0.7; font-style: italic; }
.msg-edited-tag { font-size: 10.5px; opacity: 0.65; font-style: italic; }

/* Editar mensagem direto no balão (em vez de uma janelinha do navegador) —
   o balão vira, na hora, um miniformulário com o texto atual pronto pra
   mexer. */
.msg.editing {
  width: 320px;
  max-width: 80vw;
  cursor: default;
  background: var(--panel);
  box-shadow: 0 4px 18px rgba(16,25,43,0.16);
}
.msg-edit-form { display: flex; flex-direction: column; gap: 8px; }
.msg-edit-textarea {
  width: 100%;
  min-height: 60px;
  max-height: 260px;
  resize: none;
  overflow-y: auto;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-sizing: border-box;
}
.msg-edit-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }
.msg-edit-textarea.msg-edit-error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.12); }
.msg-edit-actions { display: flex; justify-content: flex-end; gap: 6px; }
.msg-edit-actions button { padding: 0 14px; height: 30px; font-size: 12.5px; border-radius: var(--radius-sm); }

.delivery-warning {
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 5px 9px;
  margin-top: 3px;
  max-width: 62%;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #92640a;
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 90;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.msg {
  position: relative;
  max-width: 62%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
}
/* Só o texto da mensagem em si preserva quebras de linha — aplicar
   white-space: pre-wrap direto no .msg fazia até a indentação/quebras de
   linha do próprio template HTML (entre a mídia, o texto e o horário)
   aparecerem como linhas em branco de verdade dentro do balão, deixando
   ele bem maior e mais vazio do que devia (ver renderMessage em app.js). */
.msg-text { white-space: pre-wrap; }
.msg .time { font-size: 10px; color: rgba(16,25,43,0.38); margin-top: 4px; text-align: right; }
.msg.cliente { background: white; border-top-left-radius: 4px; }
.msg.tecnico { background: var(--brand-bubble); color: #0d3266; border-top-right-radius: 4px; }
.msg.bot { background: var(--bot-bubble); color: #3a2c80; border-top-right-radius: 4px; }
.msg.nota {
  background: #fff8db;
  border: 1px dashed #eadb8c;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-style: italic;
  color: #6b5e1f;
  max-width: 80%;
  box-shadow: none;
}
.msg.has-media { max-width: 300px; padding: 6px; }
.msg-image {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 10px;
  cursor: zoom-in;
  margin-bottom: 4px;
}
.msg.nota .msg-image { max-width: 220px; cursor: zoom-in; }
.msg-video {
  display: block;
  width: 100%;
  max-height: 320px;
  border-radius: 10px;
  margin-bottom: 4px;
  background: #000;
}
.msg.nota .msg-video { max-width: 220px; }
.msg-audio {
  display: block;
  width: 260px;
  max-width: 100%;
  margin-bottom: 2px;
}
.msg.nota .msg-audio { width: 220px; }

/* Documento (PDF, planilha etc) não é uma prévia visual como foto/vídeo —
   é um cartão clicável com ícone + nome do arquivo, então usa o padding
   normal de balão de texto em vez do padding apertado (6px) que .has-media
   usa pra imagem/vídeo colarem na borda do balão. */
.msg.has-document { padding: 9px 13px; max-width: 300px; }
.msg-document {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(16, 25, 43, 0.06);
  text-decoration: none;
  color: inherit;
  max-width: 100%;
}
.msg-document:hover { background: rgba(16, 25, 43, 0.1); }
.msg-document-icon { font-size: 26px; flex-shrink: 0; }
.msg-document-info { display: flex; flex-direction: column; min-width: 0; }
.msg-document-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.msg-document-hint { font-size: 11px; color: var(--text-muted); }
.msg.nota .msg-document { max-width: 220px; }

.lightbox {
  position: fixed; inset: 0;
  background: rgba(8, 14, 26, 0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 80;
  padding: 32px;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.composer-attachments {
  display: flex;
  gap: 8px;
  padding: 10px 20px 0;
  overflow-x: auto;
}
.attachment-thumb {
  position: relative;
  width: 56px; height: 56px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment-video-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #0e1c30;
  font-size: 22px;
}
.attachment-audio-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #1f1440;
  font-size: 22px;
}
/* Documento precisa mostrar o nome do arquivo pra dar pra diferenciar um do
   outro antes de mandar (diferente de foto/vídeo/áudio, onde um ícone
   sozinho já basta) — por isso esse cartão é mais largo que o quadradinho
   56x56 padrão dos outros anexos. */
.attachment-thumb.is-document { width: 132px; }
.attachment-document-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  background: #eef1f6;
}
.attachment-document-icon { font-size: 20px; flex-shrink: 0; }
.attachment-document-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(14, 28, 48, 0.7);
  color: white;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.attachment-remove:hover { background: var(--red); }
/* .composer button já dá padding/altura pro botão "Enviar" — sem isso aqui,
   essas mesmas regras (feitas pro Enviar) também pegariam o botão de anexar
   foto (é um <button> dentro de .composer também) e espremeriam o ícone até
   sumir. */
.composer .composer-attach-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  align-self: flex-end;
  margin-bottom: 1px;
}
.composer .composer-attach-btn svg { width: 19px; height: 19px; }
/* Botão de gravar áudio fica vermelho e pulsando enquanto está gravando,
   pra deixar bem claro que o microfone está ligado. */
.composer-attach-btn.recording {
  background: var(--red);
  border-color: var(--red);
  color: white;
  animation: record-pulse 1.4s ease-in-out infinite;
}
@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.record-timer {
  align-self: flex-end;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
}

.composer-wrap { background: var(--panel); border-top: 1px solid var(--border); position: relative; }
.qr-suggest {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 100%;
  margin-bottom: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}
.qr-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.qr-suggest-empty { padding: 10px 14px; font-size: 12.5px; color: var(--text-muted); }
.qr-suggest-item:last-child { border-bottom: none; }
.qr-suggest-item:hover, .qr-suggest-item.active { background: var(--brand-light); }
.qr-suggest-item .qr-suggest-shortcut { font-weight: 600; font-size: 12.5px; color: var(--brand-dark); }
.qr-suggest-item .qr-suggest-preview {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Faixa mostrada em cima do composer quando a pessoa clicou em "Responder"
   numa mensagem (feature "Responder", igual o WhatsApp) — some sozinha ao
   mandar, ou clicando no "✕"/apertando ESC. */
.reply-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 20px 0;
  padding: 6px 10px;
  background: var(--card-tint);
  border-left: 3px solid var(--brand);
  border-radius: 8px;
}
.reply-banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.reply-banner-sender { font-size: 12px; font-weight: 700; color: var(--brand-dark); }
.reply-banner-text {
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-banner-cancel {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reply-banner-cancel:hover { background: var(--border); color: var(--text); }

.composer-tabs { display: flex; gap: 4px; padding: 9px 20px 0; }
.composer-tab {
  border: none;
  background: transparent;
  padding: 6px 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.composer-tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.composer-tab.note-active.active { color: #8a6d0a; border-bottom-color: #eadb8c; }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 20px 16px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  height: 110px;
  min-height: 60px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47,111,224,0.12);
}
.composer.note-mode textarea { background: #fffdf3; border-color: #eadb8c; }
.composer.note-mode textarea:focus { box-shadow: 0 0 0 3px rgba(234,219,140,0.25); }
.composer button { padding: 0 20px; height: 40px; border-radius: var(--radius-sm); }

/* ---------- Contact panel (direita) ---------- */
.contact-panel {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 18px;
}
.contact-panel[hidden] { display: none; }

.contact-avatar-wrap { text-align: center; margin-bottom: 6px; }
.contact-name { text-align: center; font-size: 15.5px; font-weight: 800; margin-top: 12px; letter-spacing: -0.01em; }
.contact-sub { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.detail-section { margin-top: 20px; }
.detail-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 10px;
}
.detail-card {
  background: var(--card-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
}
.detail-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-soft);
  padding: 9px 0;
}
.detail-row + .detail-row { border-top: 1px solid var(--border); }
.detail-row .row-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.detail-row svg { width: 14px; height: 14px; color: var(--text-muted); }
.detail-row .wa-icon { color: var(--green); }

.history-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 6px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
  transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease;
}
.history-item:hover { box-shadow: var(--shadow-card-hover); border-color: #cfe0fa; transform: translateY(-1px); }
.history-item:hover .history-preview { color: var(--brand-dark); }
.history-item:last-child { margin-bottom: 0; }
.history-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); font-weight: 700; }
.history-preview { font-size: 12.5px; color: var(--text-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .15s ease; }
.history-empty { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Modais ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(14, 28, 48, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(1px);
}
.modal[hidden] { display: none; }
/* O modal do QR code precisa sempre aparecer por cima de outros modais
   (ex: quando é aberto a partir da tela de Configurações). */
#qr-modal { z-index: 70; }

.modal-box {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 380px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.modal-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-icon svg { width: 19px; height: 19px; }
.modal-icon-brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  box-shadow: 0 4px 10px rgba(47,111,224,0.32);
}
.modal-icon-success {
  background: linear-gradient(135deg, var(--green) 0%, #128040 100%);
  color: white;
  box-shadow: 0 4px 10px rgba(22,163,74,0.32);
}
#qr-connected-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 22px 0;
}
#qr-connected-check svg {
  width: 56px; height: 56px;
  color: var(--green);
  stroke-width: 2.4;
}
.modal-box h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.modal-box p { font-size: 13px; color: var(--text-muted); margin: 0; }
.modal-box img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.modal-box label { font-size: 12.5px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.label-optional { font-weight: 400; text-transform: none; color: var(--text-muted); opacity: 0.75; }
.modal-box input, .modal-box textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 400;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.modal-box input:focus, .modal-box textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47,111,224,0.12);
}
.modal-box textarea { height: 70px; resize: vertical; }
.inactivity-minutes-row { display: flex; gap: 12px; }
.inactivity-minutes-row label { flex: 1 1 0; }
.inactivity-minutes-row input[type="number"] { width: 100%; box-sizing: border-box; }

/* Configurações abre como tela cheia, não como um popup pequeno: o fundo
   ocupa a viewport inteira, o cabeçalho e o rodapé (Salvar/Fechar) ficam
   fixos, e só o meio (settings-page-body) rola. */
#settings-modal.settings-fullscreen {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: var(--bg);
  backdrop-filter: none;
}
#settings-modal .settings-page {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  box-shadow: none;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
#settings-modal .settings-page > .modal-header {
  flex-shrink: 0;
  margin: 0;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: white;
  position: relative;
}
#settings-modal .settings-page > .modal-header h2 { font-size: 18px; }
.settings-page-close {
  margin-left: auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  flex-shrink: 0;
}
.settings-page-close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.settings-page-close:hover { background: #f2f5fb; color: var(--text); border-color: #cfd8e8; }
#settings-modal .settings-page-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 32px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#settings-modal .settings-page > .modal-actions {
  flex-shrink: 0;
  margin: 0;
  padding: 14px 32px;
  border-top: 1px solid var(--border);
  background: white;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.days-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-weight: 400;
  font-size: 12.5px;
  color: var(--text);
}
.days-picker label {
  flex-direction: row !important;
  align-items: center;
  gap: 4px !important;
  font-weight: 600 !important;
  color: var(--text-soft) !important;
  cursor: pointer;
}
.days-picker input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; }

.shifts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.shift-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.shift-row input[type="time"] {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}
.shift-row span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.shift-remove {
  margin-left: auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.shift-remove:hover { background: #fef2f2; border-color: #fecaca; color: var(--red); }
.btn-add-shift { align-self: flex-start; margin-top: 4px; font-size: 12px; padding: 6px 12px; }

.users-list { display: flex; flex-direction: column; gap: 6px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.user-row .user-row-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-row .user-row-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.user-row .user-row-username { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.user-row .user-row-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s ease, color .15s ease;
}
.user-row .user-row-remove:hover { background: #fef2f2; color: var(--red); }
.user-row .user-row-edit {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s ease, color .15s ease;
}
.user-row .user-row-edit:hover { background: var(--brand-light); color: var(--brand-dark); }
.add-user-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.add-user-row input,
.add-user-row textarea {
  flex: 1 1 130px;
  min-width: 0;
  font-family: inherit;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.add-user-row textarea { resize: vertical; min-height: 78px; flex-basis: 260px; }
.add-user-row input:focus,
.add-user-row textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }
.add-user-row button { padding: 0 14px; font-size: 12.5px; flex-shrink: 0; }
.qr-row .user-row-name { flex-direction: column; align-items: flex-start; }
.qr-row .qr-shortcut { font-weight: 600; font-size: 12.5px; }
.qr-row .qr-content {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.user-chip {
  display: flex; align-items: center; gap: 7px;
  color: #d7deec;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
}
.user-chip-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  font-size: 10.5px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 6px; }

.settings-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-section:first-of-type { border-top: none; padding-top: 0; }

/* Abas de Configurações — cada assunto (conexão, empresa, horário,
   usuários, sistema) fica separado, em vez de tudo empilhado numa lista só
   pra rolar. */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.settings-tab {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.settings-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-tab-panel[hidden] { display: none; }
.wa-settings-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; }
.wa-settings-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.wa-settings-row .dot.connected { background: var(--green); }
.wa-settings-row .dot.connecting { background: var(--amber); }
.wa-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #92640a !important;
  font-size: 12px !important;
}

.stats-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile { background: var(--brand-light); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.stat-tile .num { font-size: 23px; font-weight: 800; color: var(--brand-dark); }
.stat-tile .label { font-size: 11px; color: var(--text-soft); margin-top: 2px; font-weight: 600; }

/* Responsivo: esconde o painel de contato em telas menores */
@media (max-width: 1100px) {
  .body-shell { grid-template-columns: 320px 1fr; }
  .contact-panel { display: none !important; }
  .brand-sub { display: none; }
}
@media (max-width: 820px) {
  .topbar-search { display: none !important; }
}

/* =====================================================================
   Módulos: Ordens de serviço, Clientes, Serviços, Produtos
   ===================================================================== */
.body-shell[hidden], .module-view[hidden], .module-btn[hidden], .module-nav[hidden] { display: none !important; }

.module-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; overflow-x: auto; }
.module-btn {
  border: none;
  background: transparent;
  color: #b8c6dc;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background .15s ease, color .15s ease;
}
.module-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; }
.module-btn.active { background: rgba(255, 255, 255, 0.16); color: white; }

.module-view { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg); padding: 22px 26px 40px; }
.module-empty { padding: 60px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
.module-page { max-width: 1100px; margin: 0 auto; }
.module-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.module-head h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.module-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.module-search {
  font-family: inherit; font-size: 13.5px; padding: 8px 12px; min-width: 240px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: white; color: var(--text);
}
.module-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }
.module-tools .btn-primary, .module-tools .btn-ghost { padding: 8px 16px; }
.module-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow-x: auto; }
.back-btn { border: 1px solid var(--border); background: white; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: var(--text-soft); }
.back-btn:hover { background: var(--brand-light); color: var(--brand-dark); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--card-tint); white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
.data-table tbody tr { cursor: pointer; transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--card-tint); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table tr.inactive td { opacity: .55; }
.tag-inactive { font-size: 10px; font-weight: 700; background: #e5e7eb; color: var(--text-muted); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }
.cell-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: white; color: var(--text-soft); font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 20px; cursor: pointer; }
.chip b { margin-left: 3px; color: var(--text-muted); }
.chip:hover { border-color: #cfd8e8; }
.chip.active { background: var(--brand-light); border-color: var(--brand); color: var(--brand-dark); }
.chip.active b { color: var(--brand-dark); }

.os-status { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.os-status.aberta { background: #fee2e2; color: var(--red); }
.os-status.em_andamento { background: #dbeafe; color: var(--brand-dark); }
.os-status.aguardando { background: #fef3c7; color: var(--amber); }
.os-status.concluida { background: #dcfce7; color: var(--green); }
.os-status.cancelada { background: #e5e7eb; color: var(--text-muted); }

/* formulários */
.modal-box.modal-wide { width: 640px; }
.modal-box select, .os-form select {
  font-family: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text); background: white; font-weight: 400;
}
.modal-box select:focus, .os-form select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-error { color: var(--red) !important; }

/* tela da OS (segue o esboço) */
.os-form { padding: 22px 26px 26px; overflow: visible; }
.os-form label, .os-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.os-form input[type="text"], .os-form input[type="datetime-local"], .os-form textarea {
  font-family: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text); font-weight: 400; background: white; width: 100%;
}
.os-form input:focus, .os-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }
.os-form input:disabled, .os-form select:disabled, .os-form textarea:disabled { background: #f3f5f9; color: var(--text-soft); }
.os-form textarea { resize: vertical; }
.os-section { margin: 22px 0 10px; padding-bottom: 6px; font-size: 15px; font-weight: 800; color: var(--navy-3); border-bottom: 1px dashed #cfd8e8; }
.os-section:first-child { margin-top: 0; }
.os-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.os-row > label { flex: 1 1 200px; max-width: 280px; }
.os-label { font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.radio-row { display: flex; gap: 14px; align-items: center; height: 36px; }
.radio-label { flex-direction: row !important; align-items: center; gap: 5px !important; font-weight: 500 !important; cursor: pointer; }
.radio-label input { accent-color: var(--brand); }
.os-client { flex: 1 1 100%; max-width: 560px; }
.client-pick { display: flex; gap: 6px; }
.client-pick input { cursor: pointer; }
.client-pick button { padding: 0 14px; flex-shrink: 0; }
.link-small { font-size: 11.5px; font-weight: 700; color: var(--navy-3); text-decoration: none; margin-top: 2px; width: fit-content; }
.link-small:hover { text-decoration: underline; color: var(--brand); }
.os-wide { width: 100%; margin-top: 4px; }

.item-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.item-n { width: 30px; height: 36px; background: #3ea5db; color: white; font-weight: 700; font-size: 12px; border-radius: 4px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.item-row label { min-width: 0; }
.item-desc { flex: 1 1 auto; }
.item-qty, .item-price, .item-total { flex: 0 0 120px; }
.item-del { width: 30px; height: 36px; border: none; background: transparent; cursor: pointer; font-size: 15px; flex-shrink: 0; opacity: .7; }
.item-del:hover { opacity: 1; }

.totals-row > label { flex: 0 1 140px; max-width: 160px; }
.total-final { color: var(--green) !important; }
.total-final input { border-color: var(--green) !important; font-weight: 800; color: var(--text) !important; }
.recalc-btn { height: 36px; padding: 0 14px; font-size: 16px; }
.os-footer { display: flex; justify-content: flex-end; margin-top: 18px; }

.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.pick-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: 1px solid var(--border); background: var(--card-tint); border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer; font-family: inherit; font-size: 13px; color: var(--text); }
.pick-item span { font-size: 11.5px; color: var(--text-muted); }
.pick-item:hover { border-color: var(--brand); background: var(--brand-light); }

/* usuários: tipo + permissões */
.user-access { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-tint); display: flex; flex-direction: column; gap: 8px; }
.user-access label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-muted); font-weight: 600; max-width: 380px; }
.user-access select { font-family: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: white; color: var(--text); }
.user-perms-title { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.user-perms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; }
.user-perms-grid .checkbox-label { font-size: 13px; }
.role-badge { font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; background: #e5e7eb; color: var(--text-soft); white-space: nowrap; }
.role-badge.role-master { background: #fef3c7; color: var(--amber); }
.role-badge.role-chamados { background: #dbeafe; color: var(--brand-dark); }
.role-badge.role-os { background: #dcfce7; color: var(--green); }
.role-badge.role-completo { background: #e6e2fb; color: var(--bot-accent); }

@media (max-width: 900px) {
  .module-view { padding: 14px 12px 30px; }
  .form-grid { grid-template-columns: 1fr; }
  .item-row { flex-wrap: wrap; }
  .item-desc { flex-basis: calc(100% - 40px); }
  .os-form { padding: 16px 14px 20px; }
}

/* ---- menu do topo com submenus ---- */
.module-nav { gap: 2px; flex: 1; justify-content: center; overflow: visible; }
.menu-group { position: relative; }
.menu-group .caret { font-size: 10px; opacity: .8; }
.menu-group .menu-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  padding: 8px 0;
  background: var(--navy-2);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 10px 24px rgba(6, 12, 22, 0.45);
  z-index: 60;
}
.menu-group:hover .menu-drop, .menu-group.open .menu-drop { display: block; }
.menu-group:hover > .module-btn, .menu-group.open > .module-btn { background: var(--navy-2); color: white; border-radius: 10px 10px 0 0; }
.menu-drop button {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  color: #dbe5f5; font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 18px; cursor: pointer;
}
.menu-drop button:hover { background: rgba(255, 255, 255, 0.1); color: white; }
.menu-new > .module-btn { color: #7dd3a8; }
.module-btn.menu-toggle { height: calc(var(--topbar-h) - 20px); }

/* ---- Início ---- */
.home-page { max-width: 1180px; }
.home-greeting { font-size: 15px; color: var(--text-soft); margin: 2px 0 14px; }
.home-greeting b { color: var(--text); }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.home-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.home-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 18px 20px 20px; }
.home-card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 800; }
.quick-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.quick-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px;
  background: white; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--text); text-align: center;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.quick-tile:hover { border-color: var(--brand); box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
.tile-icon { width: 30px; height: 30px; fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat-box { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px 14px; background: var(--card-tint); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-family: inherit; }
.stat-box b { font-size: 24px; font-weight: 800; color: var(--brand-dark); }
.stat-box span { font-size: 11.5px; color: var(--text-soft); font-weight: 600; }
.stat-box:hover { border-color: var(--brand); }
.stat-box.hot b { color: var(--green); }
.home-money { margin-top: 12px; font-size: 13px; color: var(--text-soft); }
.home-money b { color: var(--text); }
.home-actions { margin-top: 14px; }

.cal-sub { font-size: 14px; color: var(--text-soft); margin: -6px 0 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 14px; text-transform: capitalize; }
.cal-nav { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--text-soft); padding: 0 8px; }
.cal-nav:hover { color: var(--brand); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wd { font-size: 10.5px; color: var(--text-muted); padding: 6px 0; font-weight: 700; }
.cal-day { position: relative; border: none; background: transparent; font-family: inherit; font-size: 13px; color: var(--text); padding: 11px 0; border-radius: 8px; cursor: pointer; }
.cal-day.other { color: #c4cbd8; cursor: default; }
.cal-day:not(.other):hover { background: var(--brand-light); }
.cal-day.today { background: var(--brand); color: white; font-weight: 700; }
.cal-day.sel:not(.today) { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal-day.has::after { content: ''; position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: #eab308; }
.cal-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-soft); border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.dot-amber { width: 8px; height: 8px; border-radius: 50%; background: #eab308; display: inline-block; }
.cal-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.cal-item { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 12px; border: 1px solid var(--border); background: var(--card-tint); border-radius: 8px; font-family: inherit; font-size: 12.5px; cursor: pointer; color: var(--text); }
.cal-item .os-status { margin-left: auto; }
.cal-item:hover { border-color: var(--brand); }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } .module-nav { justify-content: flex-start; } }

.role-badge.role-administrador { background: #e6e2fb; color: var(--bot-accent); }
.role-badge.role-operador { background: #dbeafe; color: var(--brand-dark); }
.user-row-lock { font-size: 13px; padding: 2px 6px; opacity: .7; }

/* ---- Orçamentos e recibos ---- */
.doc-item { display: grid; grid-template-columns: minmax(180px, 1fr) 90px 110px 120px 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.doc-item.with-unit { grid-template-columns: minmax(180px, 1fr) 80px 70px 105px 110px 120px 32px; }
.doc-item input { width: 100%; min-width: 0; }
.os-totals { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 14px 0 6px; }
.total-line { display: flex; gap: 18px; justify-content: space-between; min-width: 260px; }
.total-line.grand { font-size: 17px; border-top: 1px solid var(--border, #d9deea); padding-top: 6px; }
@media (max-width: 720px) {
  .doc-item, .doc-item.with-unit { grid-template-columns: 1fr 1fr; }
  .doc-item input:first-child { grid-column: 1 / -1; }
}

/* ---- Agenda de visitas ---- */
.dot-blue { width: 8px; height: 8px; border-radius: 50%; background: #2563eb; display: inline-block; margin-left: 10px; }
.cal-day.has-visit::before { content: ''; position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: 4px; border-radius: 50%; background: #2563eb; }
.cal-day.has-visit.has::after { margin-left: -6px; }
.agenda-filter { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-soft); margin-bottom: 8px; }
.agenda-filter select { flex: 1; }
.visit-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid #2563eb; background: var(--card-tint); border-radius: 8px; font-size: 12.5px; }
.visit-item.realizada { border-left-color: #16a34a; opacity: .85; }
.visit-item.cancelada { border-left-color: #9ca3af; opacity: .6; }
.visit-main { display: flex; gap: 10px; min-width: 0; }
.visit-client { font-weight: 700; }
.visit-sub { color: var(--text-soft); font-size: 12px; }
.visit-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Campos de data e hora (iguais aos demais campos, em todo o sistema) */
input[type="date"], input[type="time"], input[type="datetime-local"] {
  font-family: inherit; font-size: 13.5px; font-weight: 500; letter-spacing: .1px;
  padding: 6px 10px; height: 35px; box-sizing: border-box; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: white; color: var(--text); cursor: pointer;
}
.os-form input[type="date"], .os-form input[type="time"], .os-form input[type="datetime-local"],
.modal-box input[type="date"], .modal-box input[type="time"] { width: 100%; }
input[type="date"]:hover, input[type="time"]:hover, input[type="datetime-local"]:hover { border-color: #b9c6dd; }
input[type="date"]:focus, input[type="time"]:focus, input[type="datetime-local"]:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12);
}
input[type="date"]::-webkit-calendar-picker-indicator, input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: .55; padding: 4px; border-radius: 6px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover, input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover { opacity: 1; background: var(--brand-light); }
.os-form .os-row.top { align-items: flex-start; }

.pick-new { margin-top: 10px; width: 100%; padding: 10px 12px; border: 1.5px dashed var(--brand); background: var(--brand-light); color: var(--brand); font-family: inherit; font-weight: 700; font-size: 13px; border-radius: 8px; cursor: pointer; }
.pick-new:hover { background: #dbe8ff; }
.link-small { display: inline-block; margin-top: 4px; font-size: 12.5px; }

/* Filtro de colaborador da agenda */
.agenda-filter { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin: 4px 0 12px; }
.agenda-filter select {
  flex: 1; min-width: 0; height: 36px; padding: 6px 34px 6px 12px; font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text); background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a99' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); appearance: none; -webkit-appearance: none; cursor: pointer;
}
.agenda-filter select:hover { border-color: #b9c6dd; }
.agenda-filter select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }

/* Card "Hoje" */
.home-today { border-left: 4px solid #cbd5e6; }
.home-today.has-items { border-left-color: #2563eb; background: linear-gradient(180deg, #f4f8ff 0, #fff 70px); }
.today-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 10px; }
.today-head h3 { margin: 0; }
.today-date { display: inline-block; font-size: 12.5px; color: var(--text-soft); }
.today-date::first-letter { text-transform: uppercase; }
.today-count { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; }
.today-count.zero { background: #e5e7eb; color: var(--text-muted); }

/* Minha conta */
.user-chip:hover { background: rgba(255,255,255,0.12); }
.breadcrumb { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--text-soft); text-decoration: underline; }
.account-page { max-width: 1040px; }
.account-card { padding: 28px 32px 30px; }
.account-title { margin: 0 0 22px; padding-bottom: 14px; font-size: 22px; font-weight: 700; color: #0f5b78; border-bottom: 1px solid var(--border); }
.account-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 22px; }
.account-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.account-grid input { height: 40px; padding: 8px 12px; font-family: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: white; color: var(--text); width: 100%; box-sizing: border-box; }
.account-grid input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,224,0.12); }
.account-grid input:disabled { background: #f1f3f7; color: var(--text-soft); }
.account-pass { margin: 26px 0 20px; border-top: 1px dashed #cfd8e8; border-bottom: 1px dashed #cfd8e8; padding: 14px 0; }
.account-pass-toggle { background: none; border: none; font-family: inherit; font-size: 17px; font-weight: 700; color: #0f5b78; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.account-pass-body { margin-top: 16px; }
.account-actions { margin-top: 6px; }
@media (max-width: 760px) { .account-grid { grid-template-columns: 1fr; } .account-card { padding: 20px 16px; } }

/* =====================================================================
   Celular (telas até 760px)
   ===================================================================== */
.nav-burger, .conv-back { display: none; }
@supports (height: 100dvh) { body, #app { height: 100dvh; } }

@media (max-width: 900px) {
  /* menu do topo vira uma gaveta aberta pelo botão ☰ */
  .nav-burger { display: inline-flex; flex-shrink: 0; }
  .topbar { gap: 8px; padding: 0 10px; }
  .module-nav {
    display: none !important; position: fixed; top: var(--topbar-h); left: 0; right: 0; z-index: 65;
    flex-direction: column; align-items: stretch; gap: 0; margin: 0; padding: 8px 10px 14px;
    background: var(--navy-2); box-shadow: 0 14px 30px rgba(6, 12, 22, 0.5); max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto;
  }
  .module-nav.nav-open { display: flex !important; }
  /* iPhone/Chrome: a barra do navegador cobre o fim da lista — sobra de espaço pra rolar até o último item */
  .module-nav { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  /* os atalhos "+ Novo" vão pro fim da lista, pra Inventário e os outros ficarem mais perto do topo */
  .module-nav .menu-new { order: 99; }
  .module-nav .module-btn { width: 100%; text-align: left; height: auto; padding: 12px 14px; font-size: 15px; border-radius: 8px; }
  .module-nav .menu-group { position: static; }
  .module-nav .menu-toggle { pointer-events: none; color: #8fa3c7; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; padding-bottom: 4px; }
  .module-nav .menu-toggle .caret { display: none; }
  .module-nav .menu-group .menu-drop { display: block; position: static; box-shadow: none; background: transparent; padding: 0 0 6px 6px; min-width: 0; }
  .module-nav .menu-drop button { padding: 12px 14px; font-size: 15px; border-radius: 8px; }
  .menu-group:hover > .module-btn, .menu-group.open > .module-btn { background: transparent; border-radius: 8px; }
  .menu-new > .module-btn { color: #7dd3a8; }
}

@media (max-width: 900px) {
  .topbar-brand .brand-text { display: none; }
  .wa-status-pill #wa-status-label { display: none; }
  .wa-status-pill { padding: 0 10px; }
  #rail-stats { display: none; }
  .user-chip #user-chip-name { display: none; }
  .user-chip { padding: 3px; }
  /* busca do topo vira uma barra embaixo do cabeçalho */
  .topbar-search:not([hidden]) {
    display: flex !important; position: fixed; top: var(--topbar-h); left: 0; right: 0; z-index: 70;
    margin: 0; border-radius: 0; padding: 10px 14px; background: var(--navy-2); max-width: none;
  }

  /* Chamados: lista OU conversa */
  .body-shell { grid-template-columns: 1fr; }
  .body-shell .conversation { display: none; }
  .body-shell.show-conv .sidebar { display: none; }
  .body-shell.show-conv .conversation { display: flex; }
  .conv-back { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; margin-right: 6px; flex-shrink: 0;
    border: 1px solid var(--border); background: white; border-radius: 8px; font-size: 17px; cursor: pointer; }
  .conv-header { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .conv-header-left { min-width: 0; flex: 1 1 100%; }
  .conv-actions { flex-wrap: wrap; gap: 6px; }
  .conv-actions .btn-ghost, .conv-actions .btn-success, .conv-actions .btn-danger { padding: 7px 10px; font-size: 12.5px; }

  /* formulários e listas */
  .os-row { gap: 10px; }
  .os-row > label, .os-field { flex: 1 1 100%; max-width: none; }
  .module-head { flex-wrap: wrap; gap: 10px; }
  .module-tools { flex-wrap: wrap; width: 100%; }
  .module-tools .module-search { flex: 1 1 100%; }
  .module-card { overflow-x: auto; }
  .data-table { min-width: 520px; }
  .modal-box, .modal-box.modal-wide { width: calc(100vw - 20px); max-width: none; max-height: calc(100dvh - 20px); overflow-y: auto; }
  .total-line { min-width: 0; width: 100%; }
  .os-totals { align-items: stretch; }
  .home-greeting { padding-top: 4px; }
}

/* ---------- Rastreamento ---------- */
.rastreio-card { padding: 16px; overflow: visible; }
.rastreio-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rastreio-actions { display: flex; gap: 8px; }
.rastreio-body { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
.rastreio-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.rastreio-mapwrap { position: relative; min-width: 0; }
#rt-map { height: 70vh; min-height: 380px; border-radius: 12px; border: 1px solid var(--border); z-index: 1; }
.rt-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); cursor: pointer; }
.rt-item:hover { border-color: var(--brand); }
.rt-item.sel { border-color: var(--brand); background: var(--brand-light); }
.rt-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.rt-info { flex: 1; min-width: 0; }
.rt-name { font-weight: 700; font-size: 14px; }
.rt-plate { font-size: 11px; font-weight: 700; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.rt-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.rt-state.on { color: #2b8a3e; font-weight: 700; }
.rt-state.off { color: #868e96; font-weight: 700; }
.rt-pin { background: none; border: none; }
.rt-pin-in { position: relative; transform: translate(-7px, -7px); white-space: nowrap; }
.rt-pin-dot { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--c), 0 2px 6px rgba(0,0,0,.35); }
.rt-pin-label { position: absolute; left: 20px; top: -3px; background: var(--c); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.rt-histbar { position: absolute; z-index: 500; left: 10px; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.rt-histbar input[type=date] { width: auto; }
.rt-native { border: 1px solid var(--border); background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.rt-native-title { font-weight: 800; margin-bottom: 6px; }
.rt-native-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.rt-native-row select { flex: 1; min-width: 160px; }
.rt-native-warn { margin-top: 8px; color: #c92a2a; font-size: 13px; font-weight: 600; }
.rt-modal .rt-check { display: flex; align-items: center; gap: 8px; }
.rt-modal .rt-check input { width: auto; }
.rt-token input { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
@media (max-width: 760px) {
  .rastreio-body { grid-template-columns: 1fr; }
  .rastreio-list { max-height: 220px; }
  #rt-map { height: 55vh; }
}

.rt-code { font-family: ui-monospace, Consolas, monospace; font-size: 28px; font-weight: 800; letter-spacing: 6px; text-align: center; padding: 10px; border: 2px dashed var(--brand); border-radius: 12px; background: var(--brand-light); user-select: all; margin: 6px 0; }
.account-vehicle { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.account-vehicle h2 { font-size: 15px; margin: 0 0 6px; }
.account-vehicle .rt-native-row input { flex: 1; min-width: 140px; text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }

/* ---------- Chamados: cabeçalho e digitação mais confortáveis ---------- */
.conversation { min-width: 0; }
.conv-header { flex-wrap: wrap; row-gap: 8px; }
.conv-header-left { flex: 1 1 300px; min-width: 0; }
.conv-header-left > div { min-width: 0; }
.conv-header h2 { overflow-wrap: anywhere; }
.conv-actions { flex-shrink: 1; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
@media (max-width: 900px) {
  .conv-actions { width: 100%; justify-content: flex-start; margin-left: 0; }
  .conv-actions .btn-success { flex: 1 1 auto; }
  .conv-header .meta { font-size: 12px; }
  .conv-company { white-space: normal; }
  .conv-body { padding-left: 10px; padding-right: 10px; }
  /* digitar: caixa de texto larga em cima, botões embaixo */
  .composer-tabs { padding: 8px 12px 0; }
  .composer { flex-wrap: wrap; padding: 8px 12px 12px; gap: 8px; }
  .composer textarea { order: -1; flex: 1 1 100%; height: 84px; min-height: 56px; font-size: 16px; }
  .composer .record-timer { order: 1; }
  .composer .composer-attach-btn { order: 1; }
  .composer #reply-send { order: 2; margin-left: auto; padding: 0 28px; }
}

/* ---------- Celular em pé: barra de baixo e toques maiores ---------- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav {
    display: flex; flex: none; background: #fff; border-top: 1px solid var(--border);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); gap: 4px; z-index: 60;
    box-shadow: 0 -4px 14px rgba(15, 30, 60, 0.08);
  }
  .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; border: 0; background: transparent; border-radius: 12px; color: var(--text-muted);
    font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer;
  }
  .bottom-nav button[hidden] { display: none; }
  .bottom-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav button.active { color: var(--brand); background: var(--brand-light); }
  #app.hide-bnav .bottom-nav, body.nav-drawer-open .bottom-nav { display: none; }
  /* a gaveta do menu fica acima da barra e não cobre */
  #app { height: 100dvh; }
  /* campos com 16px (o Android/iOS não dá zoom) e alvos de toque maiores */
  input, select, textarea { font-size: 16px; }
  .btn-primary, .btn-ghost, .btn-success, .btn-danger { min-height: 42px; }
  .ticket-item { padding-top: 14px; padding-bottom: 14px; }
  .module-btn, .menu-drop button { min-height: 46px; }
}

/* ---------- Botões de remover/excluir: sempre vermelhos (padrão do sistema) ---------- */
.ico-trash { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.item-del, .shift-remove, .user-row .user-row-remove, .msg-actions .msg-action-delete {
  color: var(--red); background: #fef2f2; border: 1px solid #fecaca; opacity: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.item-del:hover, .shift-remove:hover, .user-row .user-row-remove:hover, .msg-actions .msg-action-delete:hover {
  background: var(--red); border-color: var(--red); color: #fff;
}
.item-del { width: 36px; height: 36px; padding: 0; }
.item-del:empty { display: none; }
.shift-remove { width: 28px; height: 28px; padding: 0; border-radius: 8px; }
.shift-remove .ico-trash, .msg-actions .ico-trash { width: 14px; height: 14px; }
.user-row .user-row-remove { width: 32px; height: 32px; padding: 0; }
.msg-actions .msg-action-delete { width: 24px; height: 24px; padding: 0; border-radius: 6px; }
.item-edit { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; cursor: pointer; font-size: 15px; flex-shrink: 0; }
.item-edit:hover { border-color: var(--brand); background: var(--brand-light); }

/* OS: campo do técnico em destaque e botões fixos no topo no celular */
.os-report-box { background: #f4f8ff; border: 1px solid #cfe0ff; border-radius: 12px; padding: 10px 12px; }
.os-report-hint { font-weight: 500; color: var(--text-muted); font-size: 12px; }
.os-report-box textarea { background: #fff; }
@media (max-width: 900px) {
  .os-page .module-head { position: sticky; top: 0; z-index: 30; background: var(--bg); padding: 8px 0; margin: 0 0 6px; }
  .os-page .module-head .module-tools { width: auto; flex-wrap: nowrap; margin-left: auto; }
  .os-page .module-head h1 { font-size: 18px; }
  .os-page textarea { font-size: 16px; }
}

/* ---- assinatura do cliente na OS ---- */
.sign-box { border: 1px solid var(--border, #d6dbe4); border-radius: 12px; padding: 14px; display: grid; gap: 12px; }
.sign-done { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.sign-done img { max-width: 260px; max-height: 110px; background: #fff; border: 1px solid #cfd5df; border-radius: 8px; }
.sign-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sign-actions .btn-primary, .sign-actions .btn-ghost { min-height: 46px; }
.sign-wa { background: #1fa855 !important; border-color: #1fa855 !important; }
.sign-overlay { position: fixed; inset: 0; z-index: 200; background: #fff; color: #111; display: flex; flex-direction: column; gap: 10px; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.sign-head { display: flex; flex-direction: column; gap: 2px; font-size: 18px; }
.sign-head span { font-size: 13px; color: #556; }
.sign-name { display: grid; gap: 4px; font-size: 13px; }
.sign-name input { font-size: 16px; padding: 10px; }
.sign-hint { margin: 0; text-align: center; color: #556; font-size: 14px; }
.sign-wrap { position: relative; flex: 1; min-height: 200px; border: 2px dashed #9aa6bd; border-radius: 12px; background: #fcfcfe; }
.sign-pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.sign-line { position: absolute; left: 6%; right: 6%; bottom: 28%; border-top: 1px solid #b8c0d0; pointer-events: none; }
.sign-foot { display: flex; gap: 10px; }
.sign-foot button { flex: 1; min-height: 52px; font-size: 16px; }

/* ---- foto do produto ---- */
.photo-field { margin-top: 12px; display: grid; gap: 6px; }
.photo-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.photo-prev { width: 110px; height: 110px; border: 1px dashed #aab4c6; border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: #f6f8fb; color: #7a8599; font-size: 12px; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-btns { display: grid; gap: 8px; }
.photo-pick { cursor: pointer; text-align: center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; }
.item-del-text { color: #c62828 !important; border-color: #e7a6a6 !important; }
.item-photo { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid #cfd5df; display: block; margin-top: 6px; }
.desc-cell { display: flex; gap: 8px; align-items: center; min-width: 0; }
.desc-cell input { flex: 1; min-width: 0; }
.desc-cell .item-photo { margin: 0; width: 36px; height: 36px; }
.desc-cell .item-photo-slot:empty { display: none; }
@media (max-width: 900px) { .doc-item .desc-cell { grid-column: 1 / -1; } }

.cam-btn { cursor: pointer; display: inline-grid; place-items: center; width: 40px; height: 36px; border: 1px solid var(--border, #d6dbe4); border-radius: 8px; background: #fff; font-size: 16px; flex: none; }

/* ---- chamados: carregamento em lotes ---- */
.list-more, .load-older { display: block; width: calc(100% - 24px); margin: 10px 12px; padding: 10px; border: 1px dashed var(--border, #c9d1df); border-radius: 10px; background: transparent; color: var(--text-muted, #667); font-weight: 600; cursor: pointer; }
.load-older { width: auto; margin: 6px auto 12px; padding: 8px 16px; }
#conversation.loading, .conversation.loading { opacity: .55; transition: opacity .15s; }

/* status em botões (orçamentos) */
.seg-status { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.seg-status button { border: 1px solid var(--border); background: #fff; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 10px; cursor: pointer; }
.seg-status.sm button { font-size: 11px; padding: 4px 9px; border-radius: 16px; }
.seg-status button.on[data-st="rascunho"], .seg-status button.rascunho.on { background: #fee2e2; color: var(--red); border-color: #fca5a5; }
.seg-status button.on[data-st="aprovado"], .seg-status button.aprovado.on { background: #dcfce7; color: var(--green); border-color: #86efac; }
.seg-status button.on[data-st="recusado"], .seg-status button.recusado.on { background: #374151; color: #fff; border-color: #374151; }
.seg-status button:not(.on):hover { background: var(--card-tint); }
.data-table th.chk, .data-table td.chk { width: 34px; padding-right: 0; }
.data-table input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; }
.q-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; background: #eff6ff; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.q-bulk[hidden] { display: none; }
.q-bulk button { border: 0; font: inherit; font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.q-bulk .b-ok { background: var(--green); color: #fff; }
.q-bulk .b-no { background: #374151; color: #fff; }
.q-bulk .b-rs, .q-bulk .b-cl { background: #fff; color: var(--text-muted); border: 1px solid var(--border); }

/* agenda do dia no lugar do calendário */
.ag-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ag-top h3 { margin: 0; }
.ag-cal-toggle { border: 1px solid var(--border); background: #fff; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-soft); padding: 6px 12px; border-radius: 16px; cursor: pointer; }
.ag-cal-toggle.on { background: #dbeafe; color: var(--brand-dark); border-color: #93c5fd; }
.ag-daynav { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 8px 0 12px; padding: 8px 6px; background: var(--card-tint); border-radius: 12px; }
.ag-daynav .cal-nav { font-size: 24px; line-height: 1; padding: 2px 12px; }
.ag-daylabel { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 15px; }
.ag-daylabel b::first-letter { text-transform: uppercase; }
.ag-today { border: 0; background: transparent; color: var(--brand); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; }
#ag-cal[hidden] { display: none; }
#ag-cal { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* menu de anexar (igual WhatsApp) */
.attach-wrap { position: relative; display: inline-flex; }
.attach-menu { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 40; min-width: 190px; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 28px rgba(15, 30, 60, .18); display: flex; flex-direction: column; gap: 2px; }
.attach-menu[hidden] { display: none; }
.attach-menu button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.attach-menu button:hover { background: var(--card-tint); }
.attach-menu .am-ic { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; filter: saturate(1.1); }
.drop-over { outline: 3px dashed var(--brand); outline-offset: -6px; background: rgba(37, 99, 235, .05); }

/* ===== Modal de confirmação (dwConfirm) ===== */
.dwc-overlay{position:fixed;inset:0;z-index:100000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,23,42,.55);backdrop-filter:blur(3px);animation:dwc-fade .15s ease-out}
.dwc-box{width:100%;max-width:400px;background:#fff;color:#0f172a;border-radius:18px;padding:26px 24px 20px;text-align:center;box-shadow:0 24px 60px rgba(15,23,42,.35);animation:dwc-pop .18s cubic-bezier(.2,.9,.3,1.2)}
.dwc-icon{width:56px;height:56px;margin:0 auto 12px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:26px;background:#e0e9ff;color:#2457d6}
.dwc-t-danger .dwc-icon{background:#fee2e2;color:#dc2626}
.dwc-t-warn .dwc-icon{background:#fef3c7;color:#d97706}
.dwc-t-ok .dwc-icon{background:#dcfce7;color:#16a34a}
.dwc-title{margin:0 0 8px;font-size:1.15rem;font-weight:700}
.dwc-msg{margin:0 0 20px;font-size:.95rem;line-height:1.45;color:#475569;white-space:pre-line}
.dwc-actions{display:flex;gap:10px}
.dwc-btn{flex:1;padding:11px 14px;border-radius:10px;font:inherit;font-weight:600;cursor:pointer;border:1px solid #cbd5e1;background:#fff;color:#334155}
.dwc-btn:hover{background:#f1f5f9}
.dwc-box .dwc-ok{border-color:transparent;color:#fff;background:linear-gradient(180deg,#3b6fe0,#2457d6)}
.dwc-box.dwc-t-ok .dwc-ok{background:linear-gradient(180deg,#22c55e,#16a34a)}
.dwc-box.dwc-t-danger .dwc-ok{background:linear-gradient(180deg,#ef4444,#dc2626)}
.dwc-btn:focus-visible{outline:3px solid rgba(36,87,214,.45);outline-offset:2px}
@keyframes dwc-fade{from{opacity:0}to{opacity:1}}
@keyframes dwc-pop{from{opacity:0;transform:scale(.92) translateY(8px)}to{opacity:1;transform:none}}

/* ===== Sugestões de itens (autocomplete) ===== */
.ac-pop{position:fixed;z-index:99990;max-height:260px;overflow-y:auto;background:#fff;border:1px solid #d6dbe4;border-radius:12px;box-shadow:0 14px 36px rgba(15,23,42,.22);padding:6px;animation:dwc-fade .1s ease-out}
.ac-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:0;border-radius:8px;background:transparent;text-align:left;cursor:pointer;font:inherit;color:#0f172a}
.ac-item:hover,.ac-item.on{background:#e8efff}
.ac-item img{width:34px;height:34px;object-fit:cover;border-radius:6px;flex:none;background:#f1f5f9}
.ac-ic{width:34px;height:34px;border-radius:6px;background:#f1f5f9;display:grid;place-items:center;flex:none;font-size:16px}
.ac-name{flex:1;font-weight:600;font-size:.92rem;line-height:1.25}
.ac-price{flex:none;font-size:.85rem;color:#2457d6;font-weight:700}
button.cam-btn{padding:0}

/* ===== Feriados (Configurações) ===== */
.hol-box{margin:14px 0;padding:14px;border:1px solid var(--border,#d6dbe4);border-radius:12px;background:rgba(127,127,127,.05)}
.hol-title{margin:0 0 8px;font-size:1rem}
.hol-nav{display:flex;align-items:center;justify-content:center;gap:14px;margin:10px 0}
.hol-nav strong{min-width:56px;text-align:center}
.hol-list{max-height:260px;overflow-y:auto;border:1px solid var(--border,#d6dbe4);border-radius:10px}
.hol-row{display:grid;grid-template-columns:28px 78px 1fr auto 28px;gap:8px;align-items:center;padding:7px 10px;border-bottom:1px solid var(--border,#e3e7ee)}
.hol-row:last-child{border-bottom:0}
.hol-row.off{opacity:.55}
.hol-date small{opacity:.6;margin-left:3px}
.hol-scope{font-size:.72rem;font-weight:700;padding:2px 8px;border-radius:99px;background:#e0e9ff;color:#2457d6}
.hol-scope.hol-curitiba{background:#dcfce7;color:#15803d}
.hol-scope.hol-estadual{background:#fef3c7;color:#b45309}
.hol-scope.hol-facultativo,.hol-scope.hol-outro{background:#f1f5f9;color:#475569}
.hol-del{border:0;background:transparent;cursor:pointer;color:#dc2626;font-size:14px}
.hol-add{display:grid;grid-template-columns:150px 1fr 130px auto;gap:8px;margin-top:10px}
@media (max-width:700px){.hol-add{grid-template-columns:1fr 1fr}.hol-row{grid-template-columns:28px 70px 1fr 28px}.hol-scope{display:none}}

/* ===== Orçamento com várias propostas ===== */
.q-add-row{display:flex;gap:8px;flex-wrap:wrap}
.sec-block{border:1px solid var(--border,#d6dbe4);border-radius:12px;padding:10px 12px 12px;margin-bottom:12px;background:rgba(36,87,214,.04)}
.sec-head{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.sec-n{flex:none;width:26px;height:26px;border-radius:50%;background:#2457d6;color:#fff;display:grid;place-items:center;font-weight:700;font-size:.8rem}
.sec-title{flex:1;min-width:0;font-weight:700}
.sec-sub{flex:none;color:#2457d6;min-width:90px;text-align:right}
.sec-add{margin-top:2px}

/* ===== Estatísticas: fechados por dia ===== */
.closed-days{grid-column:1/-1;margin-top:4px}
.cd-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;font-size:13px}
.cd-tabs button{border:1px solid var(--border,#d6dbe4);background:#fff;padding:3px 10px;font-size:12px;cursor:pointer;color:var(--text-soft,#64748b)}
.cd-tabs button:first-child{border-radius:8px 0 0 8px}.cd-tabs button:last-child{border-radius:0 8px 8px 0;border-left:0}
.cd-tabs button.on{background:#2457d6;border-color:#2457d6;color:#fff}
.cd-list{max-height:280px;overflow-y:auto;padding-right:4px}
.cd-row{display:grid;grid-template-columns:78px 1fr 34px;gap:8px;align-items:center;padding:3px 0;font-size:12px}
.cd-row.we{opacity:.6}
.cd-day small{opacity:.6}
.cd-bar{height:14px;background:var(--brand-light,#e8efff);border-radius:7px;overflow:hidden}
.cd-bar i{display:block;height:100%;background:linear-gradient(90deg,#3b6fe0,#2457d6);border-radius:7px;min-width:2px}
.cd-n{text-align:right;font-weight:800;color:var(--brand-dark,#1e3a8a)}

/* Tabelas como cartões no celular */
@media (max-width: 700px) {
  .module-card { overflow-x: visible; }
  .data-table { min-width: 0; display: block; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; }
  .data-table tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { display: block; padding: 0; border: 0; grid-column: 1 / -1; min-width: 0; overflow-wrap: anywhere; }
  .data-table td:empty { display: none; }
  .data-table td[data-label]:not(.chk)::before { content: attr(data-label) ": "; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
  .data-table td:first-child:not(.chk), .data-table td.chk + td { font-size: 15px; font-weight: 700; }
  .data-table td:first-child:not(.chk)::before, .data-table td.chk + td::before { content: none; }
  .data-table td.chk { position: absolute; top: 10px; right: 12px; width: auto; grid-column: auto; }
  .data-table td.chk::before { content: none; }
  .data-table td.chk + td { padding-right: 34px; }
  .data-table td.num { text-align: left; }
}

/* Condições salvas do orçamento */
.pr-item{display:flex;align-items:center;gap:4px;padding:0}
.pr-pick{flex:1;text-align:left;background:none;border:0;padding:8px 12px;font:inherit;font-size:13px;cursor:pointer;color:inherit}
.pr-del{background:none;border:0;padding:6px 10px;font-size:16px;line-height:1;cursor:pointer;color:#94a3b8}
.pr-del:hover{color:#dc2626}
#q-contact,#q-extra,#q-pay,#q-valid,#q-deliv,#q-warr,#q-warr-s,#q-items [data-f="description"]{text-transform:uppercase}

.q-autosave{font-size:12px;color:#16a34a;align-self:center;white-space:nowrap}.q-autosave.err{color:#dc2626}

.qr-star{background:none;border:0;font-size:18px;line-height:1;cursor:pointer;color:#94a3b8;padding:4px 6px}.qr-star.on{color:#f59e0b}.qr-star:hover{color:#f59e0b}

/* Atendente responsável / transferência */
.handler-badge{display:inline-flex;align-items:center;gap:4px;padding:3px 9px;border-radius:12px;background:#e8f0fe;color:#1e40af;font-size:12px;font-weight:600;white-space:nowrap}
.handler-badge.locked{background:#fff4e0;color:#9a5b00}
.transfer-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px}
.transfer-box{background:#fff;color:#111;border-radius:12px;padding:18px;width:min(360px,100%);display:flex;flex-direction:column;gap:12px}
.transfer-box h3{margin:0;font-size:16px}
.transfer-box select{padding:9px;border:1px solid #ccc;border-radius:8px;font-size:15px}
.transfer-actions{display:flex;justify-content:flex-end;gap:8px}

/* Inventário */
.inv-chips{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0 0 12px}
.inv-chip{display:inline-flex;gap:6px;align-items:center;padding:5px 11px;border:1px solid var(--border,#d9deea);border-radius:999px;background:#fff;font-size:13px}
.inv-stock{width:100%;font-size:13px}
.inv-stock summary{cursor:pointer;color:var(--brand,#2563eb);font-weight:600}
.inv-stock div{display:flex;justify-content:space-between;max-width:420px;padding:3px 0;border-bottom:1px dashed var(--border,#d9deea)}
.module-tools select, .modal-box .form-grid select { padding: 8px 10px; border: 1px solid var(--border, #d9deea); border-radius: 8px; background: #fff; font: inherit; }

.inv-hist{margin:10px 0;font-size:13px}.inv-hist summary{cursor:pointer;font-weight:600;color:var(--brand,#2563eb)}
.inv-histlist{max-height:300px;overflow:auto;display:flex;flex-direction:column;gap:6px;margin-top:6px}
.inv-hrow{border-left:3px solid var(--border,#d9deea);padding:2px 0 2px 8px;font-size:13px}
.inv-hmeta{color:#64748b;font-size:12px}

.doc-item .serial-line { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; margin-top: -2px; }
.doc-item .serial-line input { font-size: 13px; }
.serial-hint { color: #b45309; font-size: 12px; }

.sn-box{display:flex;flex-direction:column;gap:6px;border:1px solid var(--border,#d9deea);border-radius:10px;padding:8px;background:#fff}
.sn-box:focus-within{border-color:var(--brand,#2563eb)}
.sn-box > input{border:0 !important;outline:0;box-shadow:none !important;padding:6px 4px !important;background:transparent}
.sn-chips{display:flex;flex-wrap:wrap;gap:6px}
.sn-chips:empty{display:none}
.sn-chip{display:inline-flex;align-items:center;gap:2px;border:1.5px solid #e11d48;border-radius:8px;padding:2px 4px 2px 9px;background:#fff;font-size:14px}
.sn-chip b{font-weight:600;margin-right:2px;word-break:break-all}
.sn-chip.editing{padding:2px}.sn-edit{width:200px;max-width:60vw;border:0;outline:0;font:inherit;padding:3px 6px}
.sn-btn{border:0;background:transparent;border-radius:6px;padding:4px;display:inline-grid;place-items:center;cursor:pointer;color:#475569}
.sn-btn:hover{background:#eef2f7;color:#0f172a}.sn-btn.del:hover{background:#fee2e2;color:#b91c1c}

.sn-field{display:flex;flex-direction:column;gap:4px}
.sn-title{font-size:13px;color:var(--text-muted,#64748b);font-weight:600}
.status-btns{display:flex;flex-wrap:wrap;gap:6px}
.st-btn{border:1.5px solid var(--border,#d9deea);background:#fff;color:#334155;border-radius:999px;padding:7px 14px;font:inherit;font-size:13.5px;font-weight:600;cursor:pointer}
.st-btn:hover{background:#f1f5f9}
.st-btn.on{background:var(--brand,#2563eb);border-color:var(--brand,#2563eb);color:#fff}
.st-btn.on.st-estoque{background:#16a34a;border-color:#16a34a}.st-btn.on.st-cliente{background:#2563eb;border-color:#2563eb}
.st-btn.on.st-manutencao{background:#d97706;border-color:#d97706}.st-btn.on.st-emprestado{background:#7c3aed;border-color:#7c3aed}
.st-btn.on.st-baixado{background:#64748b;border-color:#64748b}
.inv-filter{margin:0 0 10px}
.inv-actions{white-space:nowrap;text-align:right;width:1%}
.inv-actions .sn-btn{padding:6px}

.st-btn.sm{padding:4px 9px;font-size:12px;border-width:1px}
.inv-st{white-space:nowrap}.inv-st .st-btn{margin-right:4px}
@media (max-width:700px){.inv-st{white-space:normal}}

.pick-field{position:relative;display:flex;align-items:center;border:1.5px solid var(--border,#d9deea);border-radius:10px;background:#fff;transition:border-color .12s,box-shadow .12s}
.pick-field:focus-within{border-color:var(--brand,#2563eb);box-shadow:0 0 0 3px rgba(37,99,235,.12)}
.pick-field .pf-ic{padding:0 4px 0 12px;font-size:16px}
.pick-field input{flex:1;border:0 !important;outline:0;box-shadow:none !important;background:transparent;padding:11px 8px !important;font:inherit}
.pf-caret{padding:0 12px;color:#94a3b8;font-size:13px;pointer-events:none}
.pf-x{border:0;background:#eef2f7;color:#475569;width:24px;height:24px;border-radius:50%;margin-right:8px;cursor:pointer;font-size:16px;line-height:1}
.pf-x:hover{background:#fee2e2;color:#b91c1c}
.pick-pop .pk-sub{font-weight:400;color:#64748b;font-size:12px}
.pick-pop .pk-new{color:var(--brand,#2563eb);border-top:1px solid #e5e9f0;border-radius:0 0 8px 8px;margin-top:4px}
.pick-pop .pk-new .ac-ic{background:#e8efff;color:var(--brand,#2563eb);font-weight:700}

.inv-table-link, #inv-table td a{color:var(--brand,#2563eb);font-weight:600;text-decoration:none}#inv-table td a:hover{text-decoration:underline}
/* Orçamentos: os 3 botões de status ficam na mesma linha (no celular podem quebrar) */
.data-table .seg-status.sm { flex-wrap: nowrap; white-space: nowrap; }
.data-table .seg-status.sm button { white-space: nowrap; }
@media (max-width: 700px) { .data-table .seg-status.sm { flex-wrap: wrap; } }
