:root { --primary: #111; --bg: #f9f9f9; --card: #fff; --text: #333; --border: #eee; }
body { margin: 0; font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100vh; }
header { display: flex; justify-content: space-between; align-items: center; padding: 10px 40px; background: #fff; border-bottom: 1px solid var(--border); }
.logo-container { display: flex; align-items: center; }
.logo-container img { max-height: 65px; margin-right: 15px; } 

nav { display: flex; align-items: center; }
nav > a { text-decoration: none; color: #666; margin-left: 20px; font-weight: 500; cursor: pointer; font-size: 14px; }
nav > a:hover { color: var(--primary); }

.user-menu { position: relative; display: inline-block; margin-left: 30px; cursor: pointer; }
.user-menu-btn { display: flex; align-items: center; gap: 10px; background: #f5f5f5; padding: 5px 15px 5px 5px; border-radius: 30px; transition: background 0.2s; }
.user-menu-btn:hover { background: #eee; }
.user-menu-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #ddd; }
.user-menu-name { font-size: 14px; font-weight: 600; color: #333; }
.user-dropdown { display: none; position: absolute; right: 0; top: 45px; background: #fff; box-shadow: 0 8px 16px rgba(0,0,0,0.1); border-radius: 8px; border: 1px solid var(--border); min-width: 150px; overflow: hidden; z-index: 200; text-align: left; }
.user-dropdown.show {
    display: block;
}
.user-dropdown a { display: block; padding: 12px 15px; font-size: 13px; color: #333; text-decoration: none; border-bottom: 1px solid #f9f9f9; }
.user-dropdown a:hover { background: #f5f5f5; }
.user-dropdown a.logout-btn { color: #d93025; font-weight: bold; }

main { padding: 40px; max-width: 1200px; margin: 0 auto; width: 100%; box-sizing: border-box; flex: 1; }
.card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); padding: 25px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); margin-bottom: 20px; overflow: visible; }
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th { text-align: left; padding: 12px; border-bottom: 2px solid var(--border); color: #888; font-size: 12px; text-transform: uppercase; }
td { padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }

.badge { padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.badge-ativo { background: #e6f4ea; color: #1e7e34; }
.badge-bloqueado { background: #fce8e6; color: #d93025; }

.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; box-sizing: border-box; }
button { background: var(--primary); color: #fff; border: none; padding: 11px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 14px; transition: background 0.2s; }
button:hover { background: #333; }
button.secondary { background: #eee; color: #333; margin-left: 10px; }
button.secondary:hover { background: #ddd; }
button.danger { background: #d93025; color: #fff; }
button.danger:hover { background: #b3261e; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; padding: 20px; box-sizing: border-box; }
.modal-content { background: #fff; padding: 30px; border-radius: 12px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; }

.avatar-mini { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 10px; background: #ddd; }

.actions-menu { position: relative; display: inline-block; padding: 5px 10px; cursor: pointer; font-weight: bold; color: #888; }
.actions-menu:hover { background: #f0f0f0; border-radius: 4px; }
.dropdown { display: none; position: absolute; right: 0; top: 100%; background: #fff; box-shadow: 0 8px 16px rgba(0,0,0,0.1); border-radius: 8px; border: 1px solid var(--border); z-index: 150; min-width: 120px; }
.dropdown.show {
    display: block;
}
.dropdown a { display: block; padding: 10px; font-size: 13px; color: #333; text-decoration: none; font-weight: normal; }
.dropdown a:hover { background: #f5f5f5; color: var(--primary); }

.img-container { width: 100%; max-height: 400px; margin-bottom: 20px; }
.img-container img { max-width: 100%; }
.avatar-preview { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); margin-bottom: 10px; display: block; }

/* -------------------------------------------
   SISTEMAS (MUDANÇA AQUI)
------------------------------------------- */
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.sys-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; cursor: pointer; position: relative; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.sys-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.05); border-color: #ddd; }
.sys-card img { 
    width: 60px !important; 
    height: 60px !important; 
    object-fit: contain; 
    margin-bottom: 15px; 
    border-radius: 12px; 
    display: inline-block; 
}

/* Botão 3 pontos ajustado */
.sys-actions { position: absolute; top: 10px; right: 10px; padding: 5px 12px; cursor: pointer; color: #ccc; font-weight: bold; transition: 0.2s; border-radius: 4px; }
.sys-actions:hover { color: #666; background: #f0f0f0; }

/* Dropdown base e Classe de Exibição via JS */
.sys-actions .dropdown { display: none; position: absolute; right: 0; top: 100%; background: #fff; box-shadow: 0 8px 16px rgba(0,0,0,0.1); border-radius: 8px; border: 1px solid var(--border); z-index: 150; min-width: 120px; text-align: left; }
.dropdown.show { display: block !important; }

/* -------------------------------------------
   TOASTS POPUPS
------------------------------------------- */
#toast-container { position: fixed; top: 100px; right: 40px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #fff; padding: 15px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; box-shadow: 0 4px 15px rgba(0,0,0,0.1); opacity: 0; transform: translateX(100%); animation: slideIn 0.3s forwards; display: flex; align-items: center; gap: 12px; min-width: 250px; color: #333; border-left: 5px solid transparent; }
.toast.success { border-left-color: #1e7e34; }
.toast.warning { border-left-color: #f9ab00; }
.toast.error { border-left-color: #d93025; }
.toast-icon { font-size: 18px; font-weight: bold; }
.toast.success .toast-icon { color: #1e7e34; }
.toast.warning .toast-icon { color: #f9ab00; }
.toast.error .toast-icon { color: #d93025; }
.toast.fadeOut { animation: fadeOut 0.3s forwards; }

@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(120%); } }

#custom-confirm { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 10000; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; backdrop-filter: blur(2px); }
.confirm-box { background: #fff; padding: 30px; border-radius: 12px; width: 100%; max-width: 350px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.1); animation: popIn 0.2s ease-out; }
.confirm-text { margin-bottom: 25px; font-size: 16px; color: #333; line-height: 1.4; }
.confirm-btns { display: flex; gap: 10px; justify-content: center; }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Rodapé de Compliance */
footer.compliance-footer { text-align: center; padding: 30px 20px; border-top: none; background: var(--bg); color: #777; font-size: 12px; line-height: 1.6; margin-top: 40px; }
footer.compliance-footer img { max-height: 50px; display: block; margin: 0 auto 15px auto; opacity: 0.7; }
/* Bloqueia o hover antigo forçadamente, a menos que tenha recebido o clique (.show) */
.actions-menu:hover .dropdown:not(.show),
.user-menu:hover .user-dropdown:not(.show),
.user-menu-btn:hover + .user-dropdown:not(.show) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Garante que o menu só apareça de verdade quando tiver a classe .show */
.actions-menu .dropdown.show,
.user-dropdown.show {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}