:root {
  --bg: #050810;
  --bg-2: #090d1a;
  --surface: #0e1526;
  --surface-2: #141c30;
  --border: #1e2740;
  --border-light: #2a3452;
  --text: #e8edf9;
  --text-muted: #8b93ab;
  --text-faint: #565f7c;
  --accent: #0b6bf5;
  --accent-2: #0a2c6b;
  --accent-soft: rgba(11, 107, 245, 0.15);
  --accent-glow: rgba(11, 107, 245, 0.32);
  --success: #2fb571;
  --warning: #e0a53d;
  --danger: #e2586b;
  --font-display: "Sora", -apple-system, "Segoe UI", Inter, Arial, sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 640px at 20% -12%, rgba(61, 108, 240, 0.16), transparent 60%),
    radial-gradient(900px 560px at 100% 10%, rgba(20, 39, 102, 0.35), transparent 55%),
    radial-gradient(700px 500px at 50% 100%, rgba(61, 108, 240, 0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---- avisos (flash messages) ---- */
.flashes {
  list-style: none;
  padding: 0;
  margin: 1rem auto 0;
  max-width: 350px;
}

.flashes li {
  background: var(--accent-soft);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 9px;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  text-align: center;
}

/* ---- botões ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #5686f5, var(--accent));
  color: #fff;
  border: none;
  padding: 0.6rem 1.15rem;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 16px rgba(61, 108, 240, 0.25);
}

.btn:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(61, 108, 240, 0.35); }

/* ---- card genérico (login) ---- */
.card {
  background: linear-gradient(160deg, var(--surface) 0%, #0c1120 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.85rem;
  max-width: 460px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.88rem;
  font-family: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 108, 240, 0.15);
}

/* ---- login ---- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes login-glow {
  from { box-shadow: 0 0 0 rgba(61, 108, 240, 0); }
  to { box-shadow: 0 30px 70px rgba(61, 108, 240, 0.18); }
}

.login-card {
  width: 100%;
  max-width: 350px;
  animation: login-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both,
             login-glow 0.9s ease-out 0.2s both;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(61, 108, 240, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: login-rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow: hidden;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.login-card h1 {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
}

.login-card .brand-accent {
  background: linear-gradient(120deg, #7ea3ff, #3d6cf0 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-card .btn { width: 100%; margin-top: 0.25rem; }

/* ---- tela de seleção de sistema (hub) ---- */
.hub-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.hub-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 2rem;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hub-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(11, 107, 245, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.hub-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hub-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.01em;
  color: #fff;
}

.profile-prompt {
  text-align: center;
  margin-bottom: 2.6rem;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}

.profile-prompt h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}

.profile-prompt p {
  color: var(--text-muted);
  font-size: 0.98rem;
  margin: 0;
}

.profile-greeting {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
}

.profile-greeting strong {
  color: var(--text);
  font-weight: 700;
}

.profile-grid {
  display: flex;
  gap: 2.6rem;
  flex-wrap: wrap;
  justify-content: center;
  animation: rise 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.profile-empty {
  color: var(--text-muted);
  font-size: 0.92rem;
  text-align: center;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  width: 170px;
}

.profile-avatar {
  width: 150px;
  height: 150px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 2px solid transparent;
  background: linear-gradient(160deg, var(--surface) 0%, #0c1120 100%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}

.profile-avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 90px at 30% 0%, var(--accent-glow), transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.profile-avatar svg {
  width: 56px;
  height: 56px;
  position: relative;
  stroke: var(--text-muted);
  transition: stroke 0.18s ease;
}

.profile-card:hover .profile-avatar,
.profile-card:focus-visible .profile-avatar {
  transform: translateY(-6px) scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 24px 50px rgba(11, 107, 245, 0.35), 0 0 0 1px rgba(11, 107, 245, 0.25);
}

.profile-card:hover .profile-avatar svg,
.profile-card:focus-visible .profile-avatar svg {
  stroke: #fff;
}

.profile-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-muted);
  transition: color 0.18s ease;
}

.profile-card:hover .profile-name,
.profile-card:focus-visible .profile-name {
  color: var(--text);
}

.hub-footer {
  margin-top: 3.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-faint);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.footer-link:hover {
  color: var(--text-muted);
  border-color: var(--border-light);
}

.footer-link svg { width: 15px; height: 15px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
  .profile-grid { gap: 1.6rem; }
  .profile-card { width: 130px; }
  .profile-avatar { width: 110px; height: 110px; border-radius: 16px; }
  .profile-avatar svg { width: 42px; height: 42px; }
  .profile-prompt h1 { font-size: 1.5rem; }
}

/* card do admin é um <button>, precisa resetar a aparência padrão */
button.profile-card {
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
}

/* ---- popup de configurações (Área do Admin) ---- */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(3, 6, 14, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in 0.18s ease both;
}

/* o atributo [hidden] tem a mesma especificidade da classe acima, então sem
   isso aqui o "display: flex" vencia e o modal ficava visível mesmo escondido */
.admin-modal-overlay[hidden] {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.admin-modal {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: min(680px, 90vh);
  display: flex;
  background: linear-gradient(160deg, var(--surface) 0%, #0c1120 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: modal-rise 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes modal-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.admin-modal-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.admin-modal-close:hover { color: var(--text); border-color: var(--accent); }

.admin-modal-sidebar {
  width: 210px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--border);
  padding: 1.4rem 0.9rem;
}

.admin-modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 0 0.5rem;
  margin-bottom: 1rem;
}

.admin-modal-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 0.65rem;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
}

.admin-nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.admin-nav-icon svg { width: 18px; height: 18px; }

.admin-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.admin-modal-content {
  flex: 1;
  min-width: 0;
  padding: 1.6rem 1.8rem;
  overflow-y: auto;
}

.admin-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.admin-category-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
}

.admin-error {
  background: rgba(226, 88, 107, 0.12);
  border: 1px solid rgba(226, 88, 107, 0.35);
  color: #f3a5b0;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.admin-loading {
  color: var(--text-faint);
  font-size: 0.88rem;
}

.admin-empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 480px;
}

.admin-user-form {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.3rem;
}

.admin-form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.admin-form-row .field { margin-bottom: 0; }

.admin-form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-user-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  background: rgba(255, 255, 255, 0.015);
}

.admin-user-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.admin-user-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.admin-user-display {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.admin-user-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.admin-user-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.btn-danger { color: var(--danger); border-color: rgba(226, 88, 107, 0.4); }
.btn-danger:hover { background: rgba(226, 88, 107, 0.12); color: var(--danger); }

.admin-perm-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.admin-perm-group-nested {
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  margin-bottom: 0;
}

.admin-perm-group-label {
  color: var(--text-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-right: 0.3rem;
  min-width: 90px;
}

.admin-perm-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}

.admin-perm-pill input { accent-color: var(--accent); }

.admin-perm-pill:has(input:checked) {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 640px) {
  .admin-modal { flex-direction: column; height: 92vh; }
  .admin-modal-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 1rem; }
  .admin-modal-nav { flex-direction: row; }
  .admin-form-row { grid-template-columns: 1fr; }
}
