:root {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1a1e24;
  --border: #262b33;
  --text: #e8eaed;
  --text-dim: #8b92a0;
  --text-faint: #565d69;
  --accent: #ff7a33;
  --accent-dim: #7a4022;
  --live: #3ddc84;
  --live-dim: #1d4a33;
  --off: #545b66;
  --danger: #ff5c5c;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-body: "Inter", system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #dfe2e8;
  --text: #16181d;
  --text-dim: #5b6270;
  --text-faint: #8b92a0;
  --accent: #e8632a;
  --accent-dim: #ffd9c2;
  --live: #1f9d5c;
  --live-dim: #d3f3e2;
  --off: #b7bcc6;
  --danger: #d6392f;
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

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

.topbar__title h1 {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}
.topbar__title h1 .accent { color: var(--accent); }

.topbar__stats, .topbar__actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stats-row {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.stat-card { display: flex; flex-direction: column; align-items: flex-end; }
.stat-card__value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.stat-card__label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.stat-card--telegram { flex-direction: row; align-items: center; gap: 8px; }
.stat-card--telegram .stat-card__label { margin-top: 0; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--off);
  display: inline-block;
  flex-shrink: 0;
}
.dot--live {
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(61,220,132,0.5);
  animation: pulse 2s infinite;
}
.dot--on { background: var(--live); }
.dot--off { background: var(--off); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(61,220,132,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(61,220,132,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); }
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 0.85fr 1.4fr;
  gap: 24px;
  padding: 24px 32px 48px;
  align-items: start;
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
}

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

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.panel__head h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0;
  font-weight: 600;
}

.skeleton {
  color: var(--text-faint);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
  font-family: var(--font-mono);
}

/* ---------- Botões / form ---------- */

.btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn--ghost:hover { border-color: var(--text-dim); }
.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0e05;
}
.btn--accent:hover { filter: brightness(1.08); }
.btn--sm { padding: 4px 10px; font-size: 11.5px; }
.btn--danger:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }

.select, .input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-body);
}
.input { color: var(--text); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.input--sm { width: 96px; }

/* ---------- Barra de filtro do feed ---------- */

.filtro-feed {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filtro-feed input[type="text"] { flex: 1; min-width: 140px; }

/* ---------- Monitores ---------- */

.monitores-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.monitor-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .2s;
}
.monitor-card[data-ativo="false"] { opacity: 0.55; }
.monitor-card[data-erro="true"] { border-color: var(--danger); }

.monitor-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.monitor-card__nome {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.toggle {
  width: 34px;
  height: 19px;
  border-radius: 20px;
  background: var(--off);
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .15s;
}
.toggle[data-on="true"] { background: var(--live); }
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
}
.toggle[data-on="true"]::after { transform: translateX(15px); }

.monitor-card__meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}
.monitor-card__meta b { color: var(--text); font-weight: 500; }

.monitor-card__erro {
  font-size: 11.5px;
  color: var(--danger);
  font-family: var(--font-mono);
}

.monitor-card__actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Feed ---------- */

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  max-height: 760px;
  overflow-y: auto;
  align-content: start;
}

.achado {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color .15s, transform .12s;
}
.achado:hover { border-color: var(--accent); transform: translateY(-2px); }

.achado__imagem-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}
.achado__imagem-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.achado__imagem-wrap.sem-imagem::after {
  content: "sem foto";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

.achado__badge-plataforma {
  position: absolute;
  top: 8px; left: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(11,13,16,0.75);
  color: #fff;
  backdrop-filter: blur(2px);
}

.achado__corpo {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.achado__titulo {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.achado__preco {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
}

.achado__meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.empty-state {
  text-align: center;
  padding: 32px 12px;
  color: var(--text-faint);
  font-size: 13px;
}

.btn-carregar-mais {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 4px;
}

/* ---------- Toasts (achados novos) ---------- */

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--live);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: toast-entrar .18s ease-out;
}
.toast--sair { opacity: 0; transition: opacity .35s; }
@keyframes toast-entrar {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Preview de busca (testar monitor) ---------- */

.preview-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--surface-2);
  max-height: 220px;
  overflow-y: auto;
}
.preview-box__resumo {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.preview-box__lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preview-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.preview-item span { color: var(--text-dim); }
.preview-item b { font-family: var(--font-mono); color: var(--accent); flex-shrink: 0; }

/* ---------- Modal (novo/editar monitor) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,13,16,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
/* [hidden] do navegador empata em especificidade com a regra acima e
   perde no cascade (essa vem depois) — sem isso o modal fica visível
   mesmo com o atributo `hidden` setado. */
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px 24px;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal__head h3 { margin: 0; font-size: 15px; }

.modal__fechar {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.modal__fechar:hover { color: var(--text); }

.campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.campo input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-body);
}
.campo input:focus { outline: none; border-color: var(--accent); }
.campo[hidden] { display: none; }

.tipo-opcoes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.tipo-opcoes label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tipo-fixo { color: var(--text); font-weight: 500; }

.lista-dinamica {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.linha-dinamica {
  display: grid;
  grid-template-columns: 1fr 24px;
  gap: 6px;
}
.linha-dinamica input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 9px;
  font-size: 12.5px;
  font-family: var(--font-body);
}
.linha-dinamica input:focus { outline: none; border-color: var(--accent); }

.linha-filtro {
  grid-template-columns: 1.6fr 0.8fr 0.8fr 24px;
}
.linha-filtro--head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.btn-remover-linha {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.btn-remover-linha:hover { border-color: var(--danger); color: var(--danger); }

.modal__erro {
  background: rgba(255,92,92,0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Telas de autenticação (login/registro) ---------- */

.tela-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cartao-auth {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 360px;
}
.cartao-auth h1 { margin-bottom: 20px; }
.cartao-auth form { margin-top: 4px; }

.auth-nota {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 14px;
}
.auth-nota a { color: var(--accent); }

/* ---------- Admin ---------- */

.layout--admin {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 32px 48px;
}

.tabela-admin {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tabela-admin th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.tabela-admin td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tabela-admin .mono { font-family: var(--font-mono); color: var(--text-dim); }
