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

:root {
  --bg:       #0a0e1a;
  --surface:  #111827;
  --surface2: #1a2236;
  --border:   rgba(255,255,255,.08);
  --text:     #e5e7eb;
  --muted:    #6b7280;
  --accent:   #6366f1;
  --accent2:  #818cf8;
  --green:    #10b981;
  --red:      #ef4444;
  --yellow:   #f59e0b;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: #fff;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: .05em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ativas-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  background: rgba(16,185,129,.1);
  border: 1px solid rgba(16,185,129,.25);
  padding: 4px 12px;
  border-radius: 999px;
}

.ativas-badge.pulsing {
  animation: pulse-green 1.5s infinite;
}

/* ── Botões */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent2); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s;
}
.btn-outline:hover { border-color: rgba(255,255,255,.25); }

/* ── Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.card-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* ── Tabela */
.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.table-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.live-dot.connected {
  background: var(--green);
  animation: pulse-green 2s infinite;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 10px 16px;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text);
}

tr:hover td { background: rgba(255,255,255,.02); }

td.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px;
}

.row-ativa td { background: rgba(16,185,129,.04); }
.row-ativa td:first-child { border-left: 3px solid var(--green); }

/* ── Status badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.status::before { content:''; width:6px;height:6px;border-radius:50%; }
.status-ativa    { background:rgba(16,185,129,.12); color:var(--green); }
.status-ativa::before { background:var(--green); animation:pulse-green 1.5s infinite; }
.status-encerrada { background:rgba(107,114,128,.12); color:var(--muted); }
.status-encerrada::before { background:var(--muted); }
.status-iniciando { background:rgba(245,158,11,.12); color:var(--yellow); }
.status-iniciando::before { background:var(--yellow); }
.status-falhou   { background:rgba(239,68,68,.12); color:var(--red); }
.status-falhou::before { background:var(--red); }

.resolv-ia    { color:var(--green); font-weight:600; }
.resolv-humano { color:var(--yellow); }
.resolv-desc   { color:var(--muted); }

/* ── Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 28px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color:#fff; }

.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.close-btn:hover { color: var(--text); }

.modal form { display: flex; flex-direction: column; gap: 16px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.modal-note {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ── Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  animation: slide-in .2s ease;
}
.toast-ok   { border-left: 3px solid var(--green); }
.toast-err  { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

/* ── Animações */
@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Responsivo */
@media (max-width: 768px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  main { padding: 16px; }
  header { padding: 12px 16px; }
  .header-right { gap: 8px; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
}
