:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --border: #e3e7ec;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --navy: #0f2747;
  --green: #16a34a;
  --green-bg: #e7f6ec;
  --red: #dc2626;
  --red-bg: #fdeaea;
  --amber: #b45309;
  --amber-bg: #fdf1de;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- botoes ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover:not(:disabled) { opacity: .9; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .9; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0f2747, #1d3a5f);
  padding: 24px;
}
.login-card {
  background: var(--card);
  width: 100%;
  max-width: 360px;
  padding: 36px 32px;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-size: 26px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 22px; }
.login-card p { margin-bottom: 22px; }
.login-card label {
  display: block;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  margin: 14px 0 5px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.login-card input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.login-card button {
  width: 100%;
  margin-top: 22px;
}
.form-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
  text-align: left;
}

/* ---------- topbar / tabs ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  height: 56px;
}
.topbar-brand { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.topbar-brand .dot {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; opacity: .9; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .25); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); }

.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 18px;
}
.tab {
  font: inherit;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 13px 16px;
  cursor: pointer;
  color: var(--muted);
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

main { max-width: 1080px; margin: 22px auto; padding: 0 18px; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { margin-bottom: 0; }

/* ---------- badges ---------- */
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-gray { background: #eef0f3; color: var(--muted); }

/* ---------- dropzone ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px dashed #c6cdd6;
  border-radius: var(--radius);
  padding: 34px 20px;
  margin-top: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: #f5f8ff; }
.dz-icon { font-size: 26px; color: var(--primary); }

/* ---------- teste ---------- */
.test-box { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.test-box summary { cursor: pointer; font-weight: 600; }
.test-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.test-row input { flex: 1; min-width: 160px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.test-result { margin-top: 8px; font-size: 13px; }

/* ---------- summary / notes ---------- */
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.stat {
  background: #f5f7f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
}
.stat b { font-size: 18px; display: block; }
.stat span { font-size: 12px; color: var(--muted); }
.note {
  background: var(--amber-bg);
  color: var(--amber);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------- tabela previa ---------- */
.preview-actions { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.chk-inline { display: flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f5f7f9; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:last-child td { border-bottom: none; }
tr.row-off { opacity: .45; }
tr.row-invalid { background: var(--red-bg); }
.col-chk { width: 34px; }
.col-num { width: 34px; color: var(--muted); }
td input, td textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}
td input.cell-nome { min-width: 140px; }
td input.cell-tel { min-width: 130px; font-variant-numeric: tabular-nums; }
td textarea { min-height: 62px; resize: vertical; line-height: 1.45; }
.cell-msg-wrap { min-width: 280px; }
.row-warnings { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.warn {
  font-size: 10px;
  background: var(--amber-bg);
  color: var(--amber);
  padding: 1px 6px;
  border-radius: 4px;
}
.warn.warn-red { background: var(--red-bg); color: var(--red); }
.btn-regen {
  margin-top: 4px;
  font-size: 11px;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

/* ---------- send bar ---------- */
.send-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---------- progresso ---------- */
.progress-status {
  font-weight: 600;
  padding: 10px 14px;
  background: #f5f7f9;
  border-radius: 8px;
  margin-bottom: 12px;
}
.progress-list { display: flex; flex-direction: column; gap: 6px; }
.prog-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.prog-item .pi-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.pi-pending .pi-icon { background: #eef0f3; color: var(--muted); }
.pi-sending .pi-icon { background: var(--amber-bg); color: var(--amber); }
.pi-sent .pi-icon { background: var(--green-bg); color: var(--green); }
.pi-failed .pi-icon { background: var(--red-bg); color: var(--red); }
.pi-name { font-weight: 600; }
.pi-phone { color: var(--muted); font-variant-numeric: tabular-nums; }
.pi-meta { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.pi-failed .pi-meta { color: var(--red); }

/* ---------- usuarios ---------- */
.user-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.user-form label { font-size: 12px; font-weight: 600; display: block; margin-bottom: 4px; }
.user-form input, .user-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
}
.user-form-btn { display: flex; align-items: flex-end; }

/* ---------- modal ---------- */
.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
}
.modal h3 { font-size: 17px; margin-bottom: 10px; }
.modal-body-row { margin: 6px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 720px) {
  .user-form { grid-template-columns: 1fr; }
  .topbar-brand { font-size: 15px; }
}
