/* Controle BMs — tema escuro, mesmo padrão visual dos outros sites do VPS. */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
  --font-sans: 'Fira Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, Menlo, Consolas, monospace;

  --bg:        #0d0f13;
  --surface:   #161a21;
  --surface-2: #1c212a;
  --surface-3: #242b36;
  --border:    #2a313c;
  --border-2:  #3a4250;
  --text:      #e8eaed;
  --muted:     #9aa4b2;
  --faint:     #6b7280;

  --accent:     #25d366;  /* verde WhatsApp — ação primária */
  --accent-ink: #052e16;
  --blue:       #4d8dff;
  --ok:         #34d399;
  --ok-bg:      rgba(52,211,153,.13);
  --err:        #f87171;
  --err-bg:     rgba(248,113,113,.13);
  --err-bd:     rgba(248,113,113,.4);
  --warn:       #fbbf24;
  --warn-bg:    rgba(251,191,36,.13);
  --warn-bd:    rgba(251,191,36,.4);

  --r: 12px;
  --r-md: 9px;
  --r-sm: 7px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── navegação ─────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  height: 52px;
  background: rgba(13,15,19,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.nav-brand { font-weight: 700; font-size: 15px; margin-right: 20px; }
.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent-ink); background: var(--accent); }

/* ── cabeçalho ─────────────────────────────────────────────────────── */
header, main {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: 28px;
  padding-right: 28px;
}
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 20px;
}
header h1 { margin: 0; font-size: 22px; font-weight: 650; }
.toolbar { margin-left: auto; display: flex; gap: 10px; align-items: center; }
main { padding-bottom: 48px; }

/* ── campos ────────────────────────────────────────────────────────── */
input[type="text"], input[type="search"], select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  height: 36px;
  width: 100%;
  transition: border-color .12s, background .12s;
}
input:hover, select:hover { border-color: var(--border-2); }
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(77,141,255,.18);
}
#busca { width: 300px; height: 38px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.btn-primary {
  font: inherit;
  font-weight: 600;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.btn-icon svg { width: 17px; height: 17px; }
.btn-icon:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-icon:disabled { opacity: .3; cursor: default; }
.btn-del:hover { color: var(--err) !important; background: var(--err-bg) !important; }

.btn-confirm-sim, .btn-confirm-nao {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.btn-confirm-sim { background: var(--err); color: #2c0808; border: 0; }
.btn-confirm-nao { background: transparent; color: var(--muted); border: 1px solid var(--border-2); }
.btn-confirm-nao:hover { color: var(--text); }

/* ── tabela (contas) ───────────────────────────────────────────────── */
.tabela-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.inativa td.leitura { color: var(--faint); }
.col-id { width: 56px; }
.col-numero { width: 150px; }
.col-bool { width: 72px; text-align: center; }
.col-acoes { width: 200px; }
.id-cell { font-family: var(--font-mono); color: var(--faint); font-size: 12.5px; padding-left: 14px; }
.bool-cell { text-align: center; }
.acao-cell { text-align: right; white-space: nowrap; }
.vazio { padding: 28px; text-align: center; color: var(--muted); margin: 0; }

/* ── cards (demandas) ──────────────────────────────────────────────── */
.demandas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-topo { display: flex; align-items: center; gap: 8px; }
.card-topo .id-cell { padding: 0 4px; }
.demanda-nome { font-size: 16px !important; font-weight: 600; }

.contas-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.conta-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.prio {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}
.conta-item:first-child .prio { background: var(--accent); color: var(--accent-ink); }
.conta-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conta-nome { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conta-det { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conta-acoes { display: flex; flex: none; }
.sem-conta { border-color: var(--err-bd); background: var(--err-bg); }
.sem-conta .conta-nome { color: var(--err); display: inline-flex; align-items: center; gap: 6px; }
.sem-conta .conta-nome svg { width: 15px; height: 15px; }
.contas-vazia { color: var(--faint); padding: 8px 2px; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  vertical-align: 1px;
}
.tag-warn { color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-bd); }

.add-conta { color: var(--muted); cursor: pointer; }

/* ── feedback ──────────────────────────────────────────────────────── */
@keyframes flashOk  { from { box-shadow: inset 0 0 0 999px var(--ok-bg); }  to { box-shadow: none; } }
@keyframes flashErr { from { box-shadow: inset 0 0 0 999px var(--err-bg); } to { box-shadow: none; } }
.flash-ok  { animation: flashOk .9s ease-out; }
.flash-err { animation: flashErr 1.6s ease-out; }
tr.flash-ok td  { animation: flashOk .9s ease-out; }
tr.flash-err td { animation: flashErr 1.6s ease-out; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok   { background: var(--ok);  color: #06231a; }
.toast.erro { background: var(--err); color: #2c0808; }

/* ── celular ───────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header, main { padding-left: 16px; padding-right: 16px; }
  .toolbar { width: 100%; margin-left: 0; }
  #busca { flex: 1; width: auto; }
  .demandas { grid-template-columns: 1fr; }
  .nav-brand { margin-right: 8px; }
}

/* ── leitura x edição ──────────────────────────────────────────────── */
td.leitura { padding: 10px 10px; overflow-wrap: anywhere; }
tr.editando td { background: rgba(77,141,255,.07); }
tr.editando td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.card.alterado { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77,141,255,.15); }
.demanda-titulo { flex: 1; min-width: 0; margin: 0; font-size: 16px; font-weight: 600; padding: 0 4px; }
.card-rodape { display: flex; justify-content: flex-end; gap: 8px; }
.acao-cell { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
td.acao-cell { display: table-cell; }
td.acao-cell > * { vertical-align: middle; }
td.acao-cell > * + * { margin-left: 6px; }

.btn-sec, .btn-salvar {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.btn-sec { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); }
.btn-sec:hover { background: var(--surface-3); }
.btn-salvar { background: var(--accent); color: var(--accent-ink); border: 0; }
.btn-salvar:hover:not(:disabled) { filter: brightness(1.07); }
.btn-salvar:disabled { opacity: .35; cursor: default; }

.tag-on  { color: var(--ok); background: var(--ok-bg); border: 1px solid rgba(52,211,153,.35); }
.tag-off { color: var(--faint); background: var(--surface-2); border: 1px solid var(--border); }


.aviso-saida {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--warn-bd);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  color: var(--warn);
  font-weight: 500;
  z-index: 60;
  max-width: calc(100vw - 32px);
}

/* ── faixa de confirmar exclusão ───────────────────────────────────── */
.faixa-confirm {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--err-bg);
  border: 1px solid var(--err-bd);
  border-radius: var(--r-md);
}
.faixa-texto { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.faixa-texto strong { color: var(--text); font-weight: 600; }
.faixa-texto span { color: var(--muted); font-size: 13px; }
tr.tr-confirm td { padding: 4px 8px 10px; }
.card .faixa-texto { flex-basis: 100%; }
.card .faixa-confirm .btn-confirm-sim { margin-left: auto; }
[hidden] { display: none !important; }

/* ── pronto (por par demanda<->conta) ──────────────────────────────── */
.btn-pronto {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  height: 26px;
  padding: 0 10px;
  margin-right: 4px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--faint);
  background: var(--surface-3);
  border: 1px solid var(--surface-3);
  opacity: .55;
  transition: opacity .12s, background .12s, color .12s;
}
.btn-pronto:hover { opacity: .85; }
.btn-pronto.sim { opacity: 1; color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.conta-acoes { align-items: center; }
