* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0; background: #f6f7f9; color: #1f2937;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
header { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 16px 0; }
.nav { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 20px; font-weight: 700; color: #2563eb; text-decoration: none; }
nav a { margin-left: 20px; color: #4b5563; text-decoration: none; font-weight: 500; }
nav a:hover { color: #2563eb; }
main { padding: 32px 24px; }
footer { padding: 24px; text-align: center; color: #9ca3af; }

h1 { margin-top: 0; }
h2 { margin-top: 32px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 20px; }
.card-label { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: .5px; }
.card-value { font-size: 32px; font-weight: 700; margin: 8px 0 4px; color: #111827; }

.actions { margin: 16px 0 24px; display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: 9px 16px; border: 1px solid #d1d5db;
  background: #fff; color: #111827; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 500; text-decoration: none;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #fff; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }

.form-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 24px; margin-bottom: 24px;
}
.form-card label {
  display: block; margin-bottom: 14px; font-weight: 500; color: #374151;
}
.form-card input[type=text], .form-card input[type=number],
.form-card select, .form-card textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
.form-card textarea { font-family: ui-monospace, Menlo, monospace; }
.form-card .checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form-card .checkbox input { width: auto; margin: 0; }

.info-box {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
  padding: 16px 20px; margin: 16px 0; font-size: 14px;
}

.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; }

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f3f4f6; font-size: 14px; }
.table th { background: #f9fafb; font-weight: 600; color: #6b7280; font-size: 12px; text-transform: uppercase; }
.table tr:hover { background: #fafbfc; }
.table code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.row-sent { opacity: .55; }
.row-unsub { background: #fef2f2; }

.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: #f3f4f6; color: #4b5563; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px;
}
.tag-green { background: #d1fae5; color: #065f46; }
.tag-red   { background: #fee2e2; color: #991b1b; }
.tag-blue  { background: #dbeafe; color: #1e40af; }

.template-item {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 20px; margin-bottom: 12px;
}
.template-item h3 { margin: 0 0 8px; }

/* Barra de progresso do scraper */
.pbar {
  width: 100%; height: 26px; background: #f1f5f9; border-radius: 999px;
  overflow: hidden; border: 1px solid #e2e8f0;
}
.pbar-fill {
  height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb);
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: width 0.6s ease; min-width: 28px;
  background-size: 40px 40px;
  background-image: linear-gradient(90deg, #3b82f6, #2563eb),
                    linear-gradient(45deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
  animation: pbar-stripes 1.2s linear infinite;
}
.pbar-done { background: linear-gradient(90deg, #10b981, #059669); animation: none; }
.pbar-err  { background: #ef4444; animation: none; }
@keyframes pbar-stripes {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 0, 40px 0; }
}

/* Spinner inline para o badge */
.spinner {
  display: inline-block; width: 10px; height: 10px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: middle; margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Wrapper para tabelas largas - permite scroll horizontal */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ───────── MOBILE: <= 768px ───────── */
@media (max-width: 768px) {
  .container { padding: 0 14px; }
  main { padding: 18px 14px; }

  /* Header: logo em cima, nav embaixo com scroll horizontal */
  .nav {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .logo { font-size: 18px; text-align: center; }
  nav {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 18px;
    justify-content: flex-start;
  }
  nav a { margin-left: 0; font-size: 14px; flex-shrink: 0; }
  nav::-webkit-scrollbar { height: 2px; }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; margin-top: 24px; }

  /* Cards: 1 ou 2 colunas no mobile */
  .cards { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .card { padding: 14px; }
  .card-value { font-size: 22px !important; }

  /* Forms */
  .form-card { padding: 18px 16px; }
  .form-card input[type=text], .form-card input[type=number],
  .form-card select, .form-card textarea { font-size: 16px; /* evita zoom no iOS */ }

  /* Action buttons: empilha em coluna */
  .actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .actions form, .actions a, .actions span, .actions button { width: 100%; }
  .actions form button { width: 100%; }
  .actions a { text-align: center; }
  .actions span[style*="border-left"] { display: none !important; }

  /* Search bar empilha */
  .search { flex-direction: column; }
  .search input { width: 100%; }

  /* Tabela: scroll horizontal + texto menor */
  table.table { font-size: 13px; min-width: 600px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .table th, .table td { padding: 8px 10px; }

  /* Login box: fit mobile */
  .login-box { padding: 28px 22px; max-width: 100%; margin: 0 14px; }
  .login-box h1 { font-size: 20px; }

  /* Info box: padding menor */
  .info-box { padding: 12px 14px; font-size: 13px; }

  /* Footer */
  footer { padding: 16px 14px; font-size: 11px; text-align: center; }
}

/* ───────── MOBILE PEQUENO: <= 380px ───────── */
@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr !important; }
  h1 { font-size: 19px; }
  .pbar { height: 22px; }
  .pbar-fill { font-size: 11px; }
}
