:root {
  --bg: #0f0f0f;
  --bg-elevated: #1a1a1a;
  --bg-hover: #232323;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-dim: #9a9a9a;
  --text-muted: #6a6a6a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: 14px;
}

input, select {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  outline: none;
  transition: border 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }

/* === Login === */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; margin-bottom: 8px;
}
.brand-dot {
  width: 10px; height: 10px; background: var(--accent); border-radius: 50%;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .sub { color: var(--text-dim); margin-bottom: 24px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: white; width: 100%; padding: 12px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.success-msg {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  color: #6ee7b7;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

/* === Layout autenticado === */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { margin-bottom: 32px; padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  transition: all 0.15s;
}
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.active { background: var(--accent); color: white; }
.nav .icon { width: 18px; height: 18px; }
.sidebar-bottom { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 100%;
  overflow-x: hidden;
}
.main-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.main-header h1 { font-size: 26px; font-weight: 700; }

/* === Cards & Grid === */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.stat { font-size: 32px; font-weight: 700; }
.stat-label { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.section { margin-top: 32px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }

/* === Listas / tabelas === */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.page-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-hover);
  flex-shrink: 0;
  object-fit: cover;
}
.page-info { flex: 1; min-width: 0; }
.page-name { font-weight: 500; }
.page-id { color: var(--text-muted); font-size: 12px; font-family: monospace; }

.toggle {
  position: relative;
  width: 42px; height: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { left: 20px; background: white; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
th {
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td.message {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 10px;
  font-weight: 500;
}
.badge-hidden { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-visible { background: rgba(16,185,129,0.15); color: #6ee7b7; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar select { width: auto; min-width: 200px; }

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 20px;
}
.pagination button {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
}
.pagination button:hover:not(:disabled) { background: var(--bg-hover); }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .info { color: var(--text-dim); font-size: 13px; padding: 0 10px; }

.action-group { display: flex; gap: 6px; flex-wrap: nowrap; }

.recent-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: none; }
.recent-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.recent-message {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
