:root {
  --bg: #0f1220;
  --card: #1a1f36;
  --card2: #232a4d;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #6c8cff;
  --green: #35c47f;
  --warn: #f0a83e;
  --red: #ef5b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #232a4d 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--card2);
  color: var(--text);
  transition: transform .05s ease, filter .15s ease;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button.small { padding: 6px 12px; font-size: 13px; }
button.primary { background: var(--accent); color: #fff; }
button.warn { background: var(--warn); color: #201400; }
button.danger { background: var(--red); color: #fff; }
button.ghost { background: transparent; border: 1px solid #3a4370; color: var(--muted); }

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #12162b;
  border: 1px solid #303862;
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 10px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

/* ── Login ── */
.login-body { display: grid; place-items: center; }
.login-card {
  width: min(360px, 92vw);
  margin-top: 16vh;
  background: var(--card);
  padding: 32px 28px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  text-align: center;
}
.login-card .logo { font-size: 48px; }
.login-card h1 { margin: 8px 0 2px; font-size: 24px; }
.login-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card button { width: 100%; background: var(--accent); color: #fff; padding: 12px; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: rgba(20,24,45,.7);
  backdrop-filter: blur(8px); border-bottom: 1px solid #262e55;
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 22px; }
.wa-pill { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--card2); }
.wa-pill.ok { background: rgba(53,196,127,.18); color: var(--green); }
.wa-pill.warn { background: rgba(240,168,62,.18); color: var(--warn); }
.wa-pill.off { background: rgba(239,91,107,.16); color: var(--red); }

/* ── Layout ── */
.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.card {
  background: var(--card);
  border: 1px solid #262e55;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.5; }
.ok-text { color: var(--green); }

/* ── WhatsApp ── */
.wa-box { text-align: center; }
.qr { width: 260px; max-width: 80%; border-radius: 12px; background: #fff; padding: 10px; margin-top: 10px; }

/* ── Agentes ── */
.agent-list { display: flex; flex-direction: column; gap: 12px; }
.agent {
  background: var(--card2);
  border: 1px solid #303862;
  border-radius: 12px;
  padding: 14px 16px;
}
.agent.running { border-color: var(--green); box-shadow: 0 0 0 1px rgba(53,196,127,.35); }
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.agent-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #59618c; margin-right: 7px; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.badge { font-size: 11px; background: rgba(53,196,127,.2); color: var(--green); padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.agent-instr { color: var(--muted); font-size: 13px; margin-top: 10px; white-space: pre-wrap; line-height: 1.5; }

/* ── Editor inline de agente ── */
.edit-form label { display: block; font-size: 12px; color: var(--muted); margin: 4px 0 4px; font-weight: 600; }
.edit-form input, .edit-form textarea { margin-bottom: 8px; }
.edit-form textarea { line-height: 1.5; }

/* ── Log de actividad ── */
.log {
  margin-top: 10px;
  max-height: 340px;
  overflow-y: auto;
  border-radius: 10px;
  background: #12162b;
  border: 1px solid #262e55;
  padding: 6px;
  font-size: 13px;
}
.log-row {
  display: grid;
  grid-template-columns: 92px 130px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 8px;
  border-bottom: 1px solid #1e254a;
}
.log-row:last-child { border-bottom: none; }
.log-time { color: #6f79a8; font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.log-agent { color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-act { color: var(--text); word-break: break-word; }
@media (max-width: 560px) {
  .log-row { grid-template-columns: 1fr; gap: 2px; padding: 8px; }
  .log-agent { color: var(--accent); }
}
