:root {
  color-scheme: dark;
  --bg: #060404;
  --panel: #0f0707;
  --panel-2: #170b0b;
  --text: #f7ecec;
  --muted: #b98f8f;
  --accent: #e31010;
  --accent-2: #ff6a00;
  --ok: #2fcf8f;
  --warn: #ffb84d;
  --danger: #ff3b3b;
  --border: rgba(255, 106, 0, 0.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, #1a0808 0%, var(--bg) 45%, #030202 100%);
  color: var(--text);
}

img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* iOS da zoom automatico em campo com fonte < 16px ao focar -- trava a tela */
input, select, textarea { font-size: max(16px, 1em); }

/* ---- Login ---- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(15, 7, 7, 0.94);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-logo { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 16px; background: #fff; padding: 6px; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 6px; }
.login-card label {
  display: block; text-align: left; margin-top: 16px; font-size: 0.85rem; color: var(--muted);
}
.login-card input {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.04); color: var(--text);
  font-size: 1rem;
}
.login-card input:focus { outline: 2px solid var(--accent-2); }
.login-card button {
  width: 100%; margin-top: 22px; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 700; font-size: 1rem;
}
.login-card .erro { color: #ffaaaa; font-size: 0.85rem; min-height: 1.2em; margin-top: 12px; }

/* ---- App shell ---- */
.app-shell { padding: 20px; max-width: 1500px; margin: 0 auto; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 48px; height: 48px; border-radius: 12px; background: #fff; padding: 4px; }
.eyebrow { text-transform: uppercase; letter-spacing: .2em; font-size: .7rem; color: var(--accent-2); margin: 0 0 4px; }
h1, h2, h3, h4, p { margin: 0; }
.topbar h1 { font-size: 1.2rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-pill, .status-pill, .user-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border); font-size: 0.85rem;
  max-width: 100%; box-sizing: border-box;
}
.filter-pill select {
  background: transparent; color: var(--text); border: none; outline: none; font: inherit;
  min-width: 0; flex: 1;
}
.status-pill.online { color: #ffcf9e; }
.dot { width: 9px; height: 9px; border-radius: 999px; background: var(--ok); box-shadow: 0 0 10px var(--ok); flex-shrink: 0; }
.user-pill { flex-wrap: wrap; row-gap: 4px; }
.user-pill #userLogin { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.user-pill button {
  border: none; background: rgba(255,106,0,.16); color: #ffbe80; padding: 6px 12px; border-radius: 999px; font-size: 0.8rem;
  flex-shrink: 0;
}

.dashboard-grid { display: grid; gap: 18px; }
.panel {
  background: rgba(15, 7, 7, 0.92); border: 1px solid var(--border); border-radius: 20px;
  padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  /* sem isso, o grid nao deixa o card encolher alem do conteudo (a tabela
     larga dentro dele), e a PAGINA INTEIRA fica mais larga que a tela */
  min-width: 0;
}
.panel-heading { display:flex; justify-content: space-between; align-items:center; margin-bottom: 14px; flex-wrap: wrap; gap: 6px; }
.subtle { color: var(--muted); font-size: .85rem; }

.stats-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; }
.stat-card { padding: 14px; border-radius: 16px; background: var(--panel-2); border:1px solid var(--border); }
.stat-card .label { font-size: 0.8rem; color: var(--muted); }
.stat-card .value { font-size: 1.35rem; font-weight:700; margin-top:6px; }

.signal-grid { display:grid; grid-template-columns: repeat(2,minmax(220px,1fr)); gap: 14px; }
.signal-card { background: var(--panel-2); border:1px solid var(--border); border-radius:16px; padding:14px; display:flex; flex-direction:column; align-items:center; gap: 12px; }
.pie-wrap { display:flex; align-items:center; gap: 16px; flex-wrap: wrap; justify-content:center; }
.pie { width: 140px; height: 140px; border-radius: 50%; box-shadow: inset 0 0 0 10px rgba(255,255,255,.03); flex-shrink: 0; }
.pie-legend { display:flex; flex-direction:column; gap:6px; font-size:.8rem; }
.pie-legend .item { display:flex; align-items:center; gap:8px; }
.pie-legend .swatch { width:11px; height:11px; border-radius:4px; display:inline-block; flex-shrink: 0; }

.table-wrapper { overflow-x:auto; -webkit-overflow-scrolling: touch; }
table { width:100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 10px 8px; text-align:left; border-bottom: 1px solid var(--border); font-size: .88rem; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.status-badge { display:inline-block; padding:5px 10px; border-radius:999px; font-size:.75rem; font-weight:700; }
.status-badge.online { background: rgba(47,207,143,.16); color:#8ff6cb; }
.status-badge.loss { background: rgba(255,59,59,.18); color:#ffaaaa; }
.status-badge.warning { background: rgba(255,184,77,.16); color:#ffd38c; }
.status-badge.offline { background: rgba(185,143,143,.16); color:#e8cfcf; }
.status-badge.blocked { background: rgba(255,106,0,.18); color:#ffbe80; }

.link-btn {
  border: none; background: transparent; color: var(--accent-2); font-size: .8rem;
  padding: 2px 6px; margin-left: 4px; border-radius: 6px;
}
.link-btn:hover { background: rgba(255,106,0,.14); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-card h3 { margin-bottom: 2px; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.modal-card input, .modal-card select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,.04); color: var(--text); font-size: .95rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.modal-actions button {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: rgba(255,255,255,.05); color: var(--text);
}
.modal-actions button[type="submit"] {
  border: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700;
}

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 16px; }
.admin-form {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.admin-form h4 { margin-bottom: 4px; }
.admin-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.admin-form input, .admin-form select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,.04); color: var(--text); font-size: .95rem;
}
.admin-form button {
  margin-top: 4px; padding: 10px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700;
}
.admin-form .erro { color: #ffaaaa; font-size: .82rem; margin: 0; }
.admin-form .sucesso { color: #8ff6cb; font-size: .82rem; margin: 0; }

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px;
}
.pagination button {
  border: 1px solid var(--border); background: rgba(255,255,255,.05); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: .85rem;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.footer-note { margin-top: 8px; text-align:center; color: var(--muted); font-size: .78rem; }
.footer-note a { color: var(--accent-2); }

/* ---- Responsivo (celular) ---- */
@media (max-width: 720px) {
  .app-shell { padding: 12px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .filter-pill, .status-pill, .user-pill { justify-content: space-between; width: 100%; }
  .signal-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 14px; border-radius: 16px; }
  .login-card { padding: 26px 20px; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
}
