:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --lembrete: #3b82f6;
  --cobranca: #f59e0b;
  --grave: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--surface);
}

header h1 { font-size: 1.75rem; font-weight: 700; }

.badge {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge.online { background: rgba(34,197,94,0.15); color: var(--success); }
.badge.offline { background: rgba(239,68,68,0.15); color: var(--danger); }

section { margin-bottom: 2.5rem; }

section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(0,0,0,0.4);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-header .icon { font-size: 1.5rem; }

.card-header h3 { font-size: 1.1rem; flex: 1; }

.tag {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tag.lembrete { background: rgba(59,130,246,0.15); color: var(--lembrete); }
.tag.cobranca { background: rgba(245,158,11,0.15); color: var(--cobranca); }
.tag.grave { background: rgba(239,68,68,0.15); color: var(--grave); }

.card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.fields { margin-bottom: 1rem; }

.fields label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.fields input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--surface-hover);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.fields input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: none;
}

.result.success { background: rgba(34,197,94,0.1); color: var(--success); display: block; }
.result.error { background: rgba(239,68,68,0.1); color: var(--danger); display: block; }
.result.info { background: rgba(59,130,246,0.1); color: var(--primary); display: block; }

.monitor-box, .log-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 120px;
}

.monitor-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--surface-hover);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.waiting { background: var(--warning); animation: pulse 2s infinite; }
.status-dot.received { background: var(--success); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.monitor-logs, .log-box {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  max-height: 300px;
  overflow-y: auto;
}

.log-entry {
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text-muted);
}

.log-entry:last-child { border-bottom: none; }

.log-entry .timestamp { color: var(--primary); margin-right: 0.5rem; }

.empty { color: var(--text-muted); font-style: italic; text-align: center; padding: 2rem 0; }

footer {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
