:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-border: #272b35;
  --text: #e7e9ee;
  --text-dim: #9aa1b1;
  --accent: #5b8cff;
  --accent-dim: #2a3a66;
  --green: #3fbf7f;
  --yellow: #e0b341;
  --red: #e0556a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
}

.topbar .brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--text-dim); font-weight: 500; }
.topbar nav a.active { color: var(--text); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

h1 { font-size: 22px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 14px; }

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat .value { font-size: 28px; font-weight: 700; }
.stat .label { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.section { margin-bottom: 28px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--panel-border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.status-novo { background: var(--accent-dim); color: var(--accent); }
.badge.status-enriquecido { background: #2a4a4a; color: #5fd0d0; }
.badge.status-contatado_whatsapp, .badge.status-contatado_instagram { background: #2a4a2e; color: var(--green); }
.badge.status-respondeu { background: #4a3f1f; color: var(--yellow); }
.badge.status-qualificado, .badge.status-convertido { background: #1f4a2a; color: var(--green); }
.badge.status-opt_out, .badge.status-descartado { background: #4a1f26; color: var(--red); }

.badge.run-done { background: #1f4a2a; color: var(--green); }
.badge.run-running { background: #3a3a1f; color: var(--yellow); }
.badge.run-failed { background: #4a1f26; color: var(--red); }
.badge.run-stopped { background: #3a2a1f; color: var(--yellow); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { opacity: 0.9; }
.btn.secondary { background: transparent; border: 1px solid var(--panel-border); color: var(--text); }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.actions-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.action-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.action-btn:hover { border-color: var(--accent); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.usage-bar { height: 6px; background: var(--panel-border); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.usage-bar .fill { height: 100%; background: var(--accent); }
.usage-bar .fill.danger { background: var(--red); }

form.settings-form .field { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  background: #0b0d11;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; }
textarea.big { min-height: 160px; }
.help-text { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 160px; }

.pagination { margin-top: 16px; display: flex; gap: 8px; }

.log-box {
  background: #0b0d11;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
}

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #4a1f26; color: #ffb3bd; }
.alert.success { background: #1f4a2a; color: #b6f0c6; }
.alert.warning { background: #4a3f1f; color: #f0dca0; }

.muted { color: var(--text-dim); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .container { padding: 20px 14px 40px; }
}
