:root {
  --green: #25D366;
  --green-dark: #128C7E;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --text: #111b21;
  --muted: #667781;
  --border: #e9edef;
  --in: #ffffff;
  --out: #d9fdd3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.muted { color: var(--muted); }
a { color: var(--green-dark); }

/* Botões */
.btn { padding: 10px 16px; border: 1px solid var(--border); background: #fff; border-radius: 8px;
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); }
.btn:hover { background: #f5f6f6; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(135deg, var(--green-dark), var(--green)); }
.login-card { background: #fff; padding: 40px; border-radius: 16px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.brand { font-size: 34px; font-weight: 800; color: var(--text); }
.brand span { color: var(--green); }
.brand-sm { font-size: 22px; font-weight: 800; }
.brand-sm span { color: var(--green); }
.login-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; }
.login-card label { font-size: 13px; font-weight: 600; margin-top: 10px; }
.login-card input, .field input {
  padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; width: 100%; }
.login-card button { margin-top: 18px; }
.error { color: #c0392b; font-size: 14px; margin-top: 10px; min-height: 18px; }

/* Navbar */
.topnav { display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--border); }
.nav-links { display: flex; gap: 18px; flex: 1; }
.nav-links a { text-decoration: none; color: var(--text); font-weight: 600; padding: 6px 10px; border-radius: 6px; }
.nav-links a:hover { background: var(--bg); }
.nav-right { display: flex; align-items: center; gap: 12px; }

/* Container / settings */
.container { max-width: 720px; margin: 24px auto; padding: 0 16px; }
.container h1 { margin: 0 0 4px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-top: 18px; }
.card h3 { margin-top: 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.actions { display: flex; gap: 10px; margin-top: 8px; }
.msg { margin-top: 12px; font-size: 14px; min-height: 18px; }
.msg.ok { color: var(--green-dark); }
.msg.err { color: #c0392b; }

/* Chat layout */
.chat-layout { display: flex; height: calc(100vh - 57px); }
.conv-list { width: 340px; background: var(--panel); border-right: 1px solid var(--border);
  overflow-y: auto; }
.conv-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--border); }
.conv-header h2 { margin: 0; font-size: 18px; }
.conv-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.conv-item:hover { background: var(--bg); }
.conv-item.unread .conv-name { font-weight: 700; }
.conv-name { font-weight: 600; }
.conv-last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; right: 14px; top: 14px; background: var(--green); color: #fff;
  border-radius: 999px; font-size: 11px; padding: 2px 7px; }
.empty { padding: 40px 24px; text-align: center; }

.chat-panel { flex: 1; display: flex; flex-direction: column; background: #efeae2; }
#chatView { flex: 1; display: flex; flex-direction: column; height: 100%; }
.chat-top { padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--border); }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 65%; padding: 8px 12px; border-radius: 8px; font-size: 14px; line-height: 1.35;
  box-shadow: 0 1px 1px rgba(0,0,0,.06); word-wrap: break-word; }
.bubble.in { background: var(--in); align-self: flex-start; }
.bubble.out { background: var(--out); align-self: flex-end; }
.bubble-text { display: block; }
.bubble-meta { display: block; text-align: right; font-size: 10px; color: #667781; margin-top: 2px; }
.tick { color: #667781; }
.tick.read { color: #53bdeb; }
.tick.fail { color: #c0392b; }
.reply { display: flex; gap: 10px; padding: 14px 20px; background: var(--panel); border-top: 1px solid var(--border); }
.reply input { flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 15px; }
.reply-hint { display: block; padding: 0 20px 10px; background: var(--panel); }

/* Listas / páginas */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 4px; }
.page-head h1 { margin: 0; }
.small { font-size: 12px; }
.card.row { display: flex; align-items: center; justify-content: space-between; }
.row-actions { display: flex; gap: 8px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef; color: #556; margin-left: 6px; }
.pill-green { background: #d9fdd3; color: var(--green-dark); }
textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; }

/* Builder layout */
.builder { display: flex; gap: 20px; padding: 0 16px 40px; max-width: 1200px; margin: 0 auto; align-items: flex-start; }
.builder-left { flex: 1; min-width: 0; }
.builder-right { width: 380px; position: sticky; top: 16px; }
.screen-card { margin-top: 14px; }
.screen-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.q-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0; background: #fafafa; }
.q-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.q-row select { padding: 6px; border-radius: 6px; border: 1px solid var(--border); }
.q-card input, .q-card textarea { width: 100%; margin-top: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }
.chk { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.builder-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* Preview (tabs + celular) */
.preview-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { padding: 6px 12px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.tab.active { background: var(--green); color: #fff; border-color: var(--green); }
.json-preview { background: #0d1117; color: #c9d1d9; padding: 14px; border-radius: 12px; font-size: 11px;
  overflow: auto; max-height: 75vh; line-height: 1.4; }
.phone { background: #111; border-radius: 28px; padding: 14px; max-height: 78vh; overflow-y: auto; }
.phone-screen { background: #e5ddd5; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.ps-title { font-size: 11px; color: #667; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.ps-h { font-size: 17px; font-weight: 700; margin: 4px 0; }
.ps-sub { font-size: 15px; font-weight: 600; margin: 4px 0; }
.ps-body { font-size: 13px; color: #333; margin: 4px 0 10px; }
.ps-field { background: #fff; border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.ps-field > span { font-size: 12px; font-weight: 600; color: #444; display: block; margin-bottom: 4px; }
.ps-input { color: #aaa; }
.ps-opt { font-size: 13px; color: #333; padding: 2px 0; }
.ps-btn { background: var(--green); color: #fff; text-align: center; padding: 10px; border-radius: 20px;
  font-weight: 600; font-size: 14px; margin-top: 10px; }

/* Templates */
.two-col { display: flex; gap: 12px; }
.two-col .field { flex: 1; }
select { padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; }
.tpl-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pill-red { background: #ffe0e0; color: #c0392b; }
.wa-bubble { background: #fff; border-radius: 8px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.15); font-size: 14px; }
.wa-header { font-weight: 700; margin-bottom: 6px; }
.wa-body { color: #111; line-height: 1.4; white-space: normal; }
.wa-footer { color: #667781; font-size: 12px; margin-top: 8px; }
.wa-btns { margin-top: 8px; border-top: 1px solid #eee; padding-top: 4px; }
.wa-btn { text-align: center; color: #00a5f4; font-weight: 600; padding: 8px; font-size: 14px; border-top: 1px solid #f0f0f0; }

/* Disparos */
input[type=file] { margin: 8px 0; }
.preview-table { overflow-x: auto; margin-top: 12px; }
.preview-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview-table th, .preview-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.preview-table th { background: #f5f6f6; }
.var-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.var-row select, .var-row input { padding: 8px; border: 1px solid var(--border); border-radius: 6px; }
.progress { background: #eee; border-radius: 999px; height: 16px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { background: var(--green); height: 100%; width: 0; transition: width .4s; }

@media (max-width: 860px) {
  .builder { flex-direction: column; }
  .builder-right { width: 100%; position: static; }
  .two-col { flex-direction: column; }
}
