:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c232d;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* `display:flex` nas regras abaixo venceria o atributo `hidden`, e o modal
   escondido continuaria capturando os cliques da pagina inteira. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1 { font-size: 20px; margin: 4px 0; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: .2px; }
h2.mt { margin-top: 24px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }
.grow { flex: 1; }

/* Login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 12px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 600; letter-spacing: .3px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  background: none; border: 0; color: var(--muted); padding: 8px 14px;
  border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards e grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.campaign-card { cursor: pointer; transition: border-color .15s; }
.campaign-card:hover { border-color: var(--accent); }
.campaign-card h3 { margin: 0 0 4px; font-size: 15px; }

/* Form */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
  font: inherit; font-size: 13px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
select[multiple] { padding: 4px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.checks { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.checks label { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--text); font-size: 13px; }
.checks input { width: auto; margin: 0; }

/* Botões */
.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn.warn { color: var(--warn); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Status */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.pill.draft { background: #30363d; color: var(--muted); }
.pill.running { background: rgba(63,185,80,.15); color: var(--ok); }
.pill.paused { background: rgba(210,153,34,.15); color: var(--warn); }
.pill.stopped { background: rgba(248,81,73,.15); color: var(--danger); }
.pill.completed { background: rgba(47,129,247,.15); color: var(--accent); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 600; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat.ok .n { color: var(--ok); }
.stat.err .n { color: var(--danger); }

.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-bottom: 18px; }
.progress .bar { height: 100%; background: var(--ok); width: 0; transition: width .4s; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.status-sent { color: var(--ok); }
.status-error { color: var(--danger); }
.status-pending { color: var(--muted); }

.result {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; margin-top: 10px;
}

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.modal-card { width: 640px; max-height: 88vh; overflow-y: auto; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface-2);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 8px; max-width: 380px; z-index: 20; font-size: 13px;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
