:root {
  --primary: #0098f9;
  --primary-hover: #0079c7;
  --text: #000000;
  --muted: #6e6e6e;
  --label: #4f4f4f;
  --border: #d8d8d8;
  --border-soft: #f2f2f2;
  --hover-bg: #f2f2f2;
  --page-bg: #f2f2f2;
  --card-bg: #ffffff;
  --active-bg: #e9f6ff;
  --danger: #cf1322;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: #fff;
}

.hidden { display: none !important; }
code {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ===================== botões ===================== */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-large { padding: 10px 18px; font-size: 0.95rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--hover-bg); }
.btn-outline.btn-danger { color: var(--danger); border-color: #ffccc7; }
.btn-outline.btn-danger:hover:not(:disabled) { background: #fff1f0; }
.btn-text { background: transparent; color: var(--label); font-weight: 500; padding: 6px 10px; }
.btn-text:hover { color: var(--text); }
.btn-icon { padding: 9px 12px; }
.btn-facebook { background: #1877f2; color: #fff; }
.btn-facebook:hover:not(:disabled) { background: #166fe5; }
.btn-facebook svg { width: 18px; height: 18px; fill: #fff; flex: none; }

/* ===================== tags/pills ===================== */
.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  display: inline-block;
  line-height: 1.6;
  border: 1px solid transparent;
}
.tag-default { background: #f5f5f5; color: #595959; border-color: #d9d9d9; }
.tag-green { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
.tag-gold { background: #fffbe6; color: #ad6800; border-color: #ffe58f; }
.tag-red { background: #fff1f0; color: #cf1322; border-color: #ffccc7; }
.tag-blue { background: #e6f7ff; color: #096dd9; border-color: #91d5ff; }
.tag-purple { background: #f9f0ff; color: #722ed1; border-color: #d3adf7; }

/* ===================== alertas ===================== */
.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  border: 1px solid transparent;
}
.alert-info { background: #e6f7ff; border-color: #91d5ff; color: #096dd9; }
.alert-warning { background: #fffbe6; border-color: #ffe58f; color: #ad6800; }
.alert-error { background: #fff1f0; border-color: #ffccc7; color: #cf1322; }
.alert-banner { border-radius: 0; border-width: 0 0 1px; margin: 0; padding: 10px 32px; }

/* ===================== login ===================== */
.login-screen {
  min-height: 100vh;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.login-brand { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.login-logo { font-weight: 800; font-size: 24px; color: var(--text); letter-spacing: -0.02em; }
.login-subtitle { font-size: 14px; color: var(--label); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--label); }
.field input {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  font-size: 0.9rem;
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,152,249,0.15); }

/* ===================== shell / header ===================== */
.wc-shell { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
.wc-header { padding: 24px 32px 0; border-bottom: 1px solid var(--border-soft); }
.wc-header-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wc-title { font-size: 1.15rem; font-weight: 700; margin: 0; color: var(--text); }
.wc-header-actions { display: flex; align-items: center; gap: 12px; }
.wc-tabs { display: flex; gap: 4px; margin-top: 14px; }
.tab {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-family: inherit;
}
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.wc-main { flex: 1; min-height: 0; padding: 24px 32px 40px; display: flex; flex-direction: column; gap: 20px; max-width: 1100px; width: 100%; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 20px; }

/* ===================== content card ===================== */
.content-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.content-card-quiet { border-color: var(--border-soft); }
.content-card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.content-card-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.82rem; line-height: 1.6; margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===================== inbox ===================== */
.wc-inbox { display: grid; grid-template-columns: 300px 1fr; gap: 16px; min-height: 560px; }
@media (max-width: 800px) { .wc-inbox { grid-template-columns: 1fr; } }
.inbox-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.search-input {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  font-size: 0.9rem;
  font-family: inherit;
}
.contact-scroll { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.contact-item { padding: 12px 14px; border-radius: var(--radius); cursor: pointer; }
.contact-item:hover { background: var(--hover-bg); }
.contact-item.active { background: var(--active-bg); }
.contact-item .name { font-weight: 600; font-size: 14px; color: var(--text); }
.contact-item .preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thread-panel { min-height: 0; }
.thread-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.thread { flex: 1; overflow-y: auto; padding: 14px 4px; display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 68%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.bubble.in { background: #fff; border: 1px solid var(--border); align-self: flex-start; }
.bubble.out { background: var(--active-bg); align-self: flex-end; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); text-align: right; margin-top: 4px; }
.bubble .origin-tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--border-soft); color: var(--muted); margin-right: 6px; }

.composer { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.composer input { flex: 1; height: 40px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; font-size: 0.9rem; font-family: inherit; }

/* ===================== templates ===================== */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form-full { grid-column: 1 / -1; }
.grid-form textarea { grid-column: 1 / -1; }
.grid-form input, .grid-form select, .grid-form textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  height: 40px;
}
.grid-form textarea { height: auto; }
.template-item { padding: 12px 0; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.template-item:last-child { border-bottom: none; }
.template-item .name { font-weight: 600; font-size: 14px; color: var(--text); }
.template-item .meta { font-size: 12px; color: var(--muted); }
.template-item .actions { display: flex; align-items: center; gap: 10px; }

/* ===================== contatos ===================== */
.directory-item { padding: 12px 0; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.directory-item:last-child { border-bottom: none; }
.directory-item .name { font-weight: 600; font-size: 14px; color: var(--text); }
.directory-item .phone { font-size: 12px; color: var(--muted); }

/* ===================== campanhas ===================== */
.campaigns-header { display: flex; justify-content: space-between; align-items: center; }
.wc-section-title { font-size: 20px; font-weight: 700; color: var(--text); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 20px; border-bottom: 1px solid var(--border-soft); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .link-btn { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; font-size: 0.88rem; font-family: inherit; }
.data-table .link-btn:hover { color: var(--primary-hover); text-decoration: underline; }

/* ===================== modal ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 560px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border-soft); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-soft); }
.modal select {
  height: 40px; width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 12px; font-size: 0.9rem; font-family: inherit; background: #fff;
}
.checkbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 180px; overflow-y: auto; }
.checkbox-list label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text); }
.campaign-add-contact { border-top: 1px solid var(--border-soft); padding-top: 14px; }

/* ===================== drawer ===================== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 200; display: flex; justify-content: flex-end;
}
.drawer {
  background: #fff; width: 420px; max-width: 100%; height: 100%;
  display: flex; flex-direction: column; box-shadow: -8px 0 32px rgba(0,0,0,0.15);
}
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border-soft); }
.drawer-header h3 { margin: 0; font-size: 1.05rem; }
.drawer-body { padding: 16px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.drawer-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }

/* ===================== toast ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  max-width: 80vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 100;
}
.toast.error { background: var(--danger); }
.toast.success { background: #065f46; }
